Donner la liste de tous les comptes et uniquement ceux-là, issus du fichier passwd triés par ordre alphabétique. Le résultat sera mis dans le fichier /tmp/out. Vous utiliserez cut et sort.
cat /etc/passwd | cut -d : -f1 | sort >> /tmp/out cat /etc/passwd | cut -d : -f1 | sort > /tmp/out && cat /tmp/out
ls /usr/bin/ | wc -l
ls -l /usr/bin/ | grep '^-' | wc -l
find /usr/bin/ -type f | wc -l
find /usr/share/doc | grep '\.gz$' | wc -l find /usr/share/doc -name *.gz | wc -l find /usr/share/doc -type f -name "*.gz" | wc -l
ps aux | grep bash
cat /etc/passwd | tr '\n' '\r' > /tmp/newpasswd
Cette commande remplace tous les passages à la ligne par un retour chariot dans le fichier /etc/passwd et écrit le résultat dans /tmp/newpasswd
le résultat de la commande cat est passé à la commande tr qui va créer une nouvelle ligne avec un retour chariot dans un fichier /tmp/passwd
sort -n /tmp/test.txt
cat /tmp/test.txt | cut -d / -f 2 > /tmp/newtest.txt
sort -r /tmp/newtest.txt echo -e '/aa\n/bb\n/cc\n/dd\n/ee' | nl | sed 's/^[ \t]*//' | tr -d [:blank:] | tr -d [:digit:] | tr -d / | sort -r >> ok echo -e '/aa\n/bb\n/cc\n/dd\n/ee' | nl -n ln | tr -d [:blank:] > /tmp/ok.bak && cat /tmp/ok.bak | tr -d [:digit:] | tr -d / | sort -r > /tmp/ok && cat /tmp/ok
find /etc -maxdepth 1 -type f | grep '\.conf' | wc -l grep pas nécessaire : mêmes les fichiers sans extension .conf peuvent être des fichiers de configuration find /etc/ -maxdepth 1 -type f -prune | wc -l
find /etc -maxdepth 1 -type d | grep 'conf' | wc -l grep pas nécessaire find /etc/ -maxdepth 1 -type d | wc -l
sudo find . -type f > /tmp/files-list.txt find . -maxdepth 1 -type f | tr -d /. > /tmp/ok ls -l | grep ^- >> /tmp/ok
ls -l | grep '^-' > /tmp/files.list
find . -maxdepth 1 -type f -ls > /tmp/files.list ls -lh >> ok && sed -i '/^d/d' /tmp/ok ls -lh | grep ^- >> /tmp/ok
ls -l | grep '^l'
OU
find . -maxdepth 1 -type l ls -la | grep ^l
man ls | grep file -i | wc -l man ls | grep -i file | wc -w -l
find /usr/bin -type f -ls | sort -k 7 -rn | head
ls -l /usr/bin/ -S | head -11
find /usr/bin/ -type f | xargs du -s | sort -rn | head
find /usr/bin/ -type f -exec du -s {} \; | sort -rn | head
ls -lSh /usr/bin/ | head -n 11
grep '^a' regexp/zola_curee.txt -i -c
J’ai remplacé le . par un retour à la ligne, ensuite j’ai viré les espaces de début de ligne, j’ai ensuite compté le nombre de ligne commençant par A
sed 'y/\./\n/' zola_curee.txt | sed 's/^ //' >> ok && sed -n '/^[Aa]/p' ok | wc -l
grep '[[:digit:]]' regexp/zola_curee.txt -c
sed -n '/[0-9]/p' zola_curee.txt | wc -l
grep '[[:punct:]]$' regexp/zola_curee.txt | grep -cv '\.$'
sed -n '/[\,\;\:\?\!]$/p' zola_curee.txt | wc -l
sed 's/\b/\n/g' regexp/zola_curee.txt | grep '^.r'
grep -o '\b\wr' regexp/zola_curee.txt | wc -l
sed 's/\b/\n/g' regexp/zola_curee.txt | grep -i '^.r' --color=always | sort -u | wc -l cat zola_curee.txt | grep '\<.r' | wc -l 247 cat zola_curee.txt | grep -E '(\b.\Br)' | wc -l 247 regex: groupe ( ) boundary word \b. non-word boundary \Br
sed 's/\b/\n/g' regexp/zola_curee.txt | grep '.r'
sed 's/\b/\n/g' regexp/zola_curee.txt | grep '.r' | wc -l
cat zola_curee.txt | grep -E '(r\w+)' | wc -l
grep 'the' regexp/texte_01.txt
grep 'the' regexp/texte_01.txt | wc -l
grep -n 'the' regexp/texte_01.txt | cut -d : -f1 | column
cat texte_01.txt | grep -i -o -n 'the' | wc -w
cat texte_01.txt | grep -i -o -n 'the' && cat texte_01.txt | grep -i -o -n 'the' | wc -l
sed 's/\b/\n/g' regexp/texte_01.txt | grep '^NASA$' | wc -l
grep -i -o 'nasa' texte_01.txt | wc -w
grep '^$' regexp/texte_01.txt | wc -l
sed -n '/^$/p' texte_01.txt | wc -l
sed 's/\s/\n/g' regexp/texte_01.txt | grep -E '^[0-9]+$' | column
Tout dépend de ce qu’on cherche exactement…
sed 's/\s/\n/g' regexp/texte_01.txt | grep -E '^[0-9]+$' | sort -nu | wc -l
cat texte_01.txt | grep -P '(\d+)' | wc -l
-P, c’est pour –perl-regexp
find /usr/bin -type f -executable | cut -d / -f4 | grep -E '^..$'
OU
find /usr/bin -type f -executable | grep -E '^/usr/bin/..$'
ls /usr/bin/ | sed -n '/^..$/p'
sed -e 's/</\n</g' -e 's/>/>\n/g' regexp/page.html | grep '^<.*>$'
sed -e 's/</\n</g' -e 's/>/>\n/g' regexp/page.html | grep '^<.*>$' | sort -u | wc -l
cat page.html | grep -P -o '(<\w+|\/\w+>)' | tr -d \/ | tr -d \< | tr -d \> | sort -u
cat page.html | grep -P -o '(^<(\w+))' | tr -d \< | sort -u
grep '<strong>' regexp/page.html | wc -l
sed -n '/<b>/p' page.html oui le doc contient bien des balises <b><b/>
sudo find /etc -type f | grep -Ei '\/[a-z]+[^\.\/]*[a-z]+[^\.\/]*[a-z]+[^\.\/]*[a-z]+\.[^\/]*$'
sudo ls -R /etc/ | sed '/.{4,}\..{3}/p' | more
sudo apt install rename rename 's/\.test/.old/' *.test
find ~ -name "*.test" -type f -exec bash -c "mv '{}' \`dirname '{}'\`/\`basename '{}' .test\`.old" \;
find . -maxdepth 1 -type f | while IFS= read -r f; do f="$(basename $f)" f="$(sed 's/[^a-z]//g' <<< "$f")"; f="${f:0:3}"; echo ">> $f matching '/[$f]{3,}.*$'"; find /etc/ -maxdepth 1 -type f | grep -E --color=always "/.*[$f]{3,}.*$"; done
ls | cut -c 1-3 | uniq | xargs -I letters find /etc -maxdepth 1 -name '*letters*'
xargs va faire une boucles
ls | cut -c 1-3 | uniq | xargs -I lettres find /etc/ -maxdepth 1 -name '*lettres*'
sudo find . -type f -mmin -10 find ~ -type f -mmin -10
sudo find . -type f -ctime -1 sudo find . -type f -ctime -2 sudo find . -type f -ctime -7
→ mtime = modification des datas → ctime = modification du status
http://www.expreg.com/symbole.php
echo -e "\nToday\n*****"; find ~ -type f -mtime -1 && echo -e "\nHier\n****"; find ~ -type f -mtime +1 && echo -e "\n7Jours\n*******"; find ~ -type f -mtime +6