La commande sed "Stream EDitor" sert à transformer des chaines de caractères.
root@debian:~# sed -n "$=" input.txt
root@debian:~# sed -n 3p input.txt
root@debian:~# sed -n -e '$p' input.txt
root@debian:~# sed -n 1~2p input.txt
root@debian:~# sed -n '/motif/p' input.txt root@debian:~# echo '1601565366' |sed -n '/^[0-9]\+$/p' 1601565366 root@debian:~# echo '1601565366' |sed -n '/^[0-9]\{10\}$/p' 1601565366 root@debian:~# echo '1601565366' |sed -n '/^[0-9]\{9\}$/p' root@debian:~#
root@debian:~# sed -n '/motif/!p' input.txt
root@debian:~# sed -e 's/bonjour/bonsoir/g' -e 's/matin/soir/g' input.txt
root@debian:~# sed -e '/^$/d' input.txt
root@debian:~# sed -e 's/ *$//' input.txt
root@debian:~# sed -e '/GUI/d' input.txt
root@debian:~# sed -e 's/GUI//g' input.txt
root@debian:~# sed -e 's/GUI.*//g' input.txt
root@debian:~# sed -e 's/bonjour/bonsoir/' input.txt
root@debian:~# sed -e 's/bonjour/bonsoir/g' input.txt
root@debian:~# CNXSC=`grep ^CNXSC ${INIFILE} |sed -e 's/CNXSC=//' -e 's/\"//g'`
root@debian:~# sed -n -e 's/...\(chaine1\)...\(chaine2\)...\(chaine3\).../\3;\1;\2/p' input.txt
root@debian:~# sed -e 's/...\(chaine1\)...\(chaine2\)...\(chaine3\).../\3;\1;\2/' input.txt
root@debian:~# echo "orange pomme" | sed -e 's/\(\<[a-zA-Z]\)\([a-zA-Z]*\>\)/\u\1\L\2/g'
root@debian:~# echo fr |sed -e 's/\(.*\)/\U\1/g'
root@debian:~# echo tRx |sed -e 's/\(.*\)/\L\1/g'
root@debian:~# echo tRX |sed -e 's/\(.*\)/\L\1/g' |sed -e 's/\(t\)/\u\1/g' |sed -e 's/\(r\)/\u\1/g'
root@debian:~# find /tmp/spool/abcd/ -type f -name "*.txt" -print 2>/dev/null |head -5 /tmp/spool/abcd/20100122192009-1034755105-1-103475510500001-20740-92-8390.txt /tmp/spool/abcd/20100122192432-1034792538-1-103479253800001-22190-92-8418.txt /tmp/spool/abcd/20100122192653-1034824097-1-103482409700001-22190-92-8418.txt /tmp/spool/abcd/20100122192308-1034773157-1-103477315700001-22190-92-8418.txt /tmp/spool/abcd/20100122192024-1034760083-1-103476008300001-20740-92-8390.txt root@debian:~# for file in $(find /tmp/spool/abcd/ -type f -name "*.txt" -print 2>/dev/null) do mydir=`echo $file|sed -e 's/.*\/.*\/.*\/.*\/\([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\).*/\1/'` mv -v $file /tmp/spool/sorted/$mydir/ done
root@debian:~# for file in $(ls -1 *.txt) do sed -e 's/3938.*/3938995642/' $file > $file.tmp mv -v $file.tmp $file done
root@debian:~# while read -r myfile; do echo "myfile=${myfile}" cp -pv ${myfile} ${myfile}.$(date +"%Y%m%d%H%M") sed -i -e "s/timeout = 15000/timeout = 30000/" ${myfile} done <<< "$( grep -l "timeout = 15000" /tmp/*.txt )"