sed

useful sed commands

Delete the lines containing string using sed

sed -i '/Baeldung/d' myfile.txt

Replace tabs with commas

sed -i 's/\t/,/g' file [file]... 

Replace carriage return in files

To replace carriage return in .sh files trasnferred from windows to linux

for file in <files>; do sed 's/\r//g' "${file}" > "${file%.sh}-fixed.sh"; done

s/\r//g the whole sed pattern

s/ substitute

carriage return

// by nothing

/g globally

${file%.sh} strip the .shfrom the filename

Last updated