sed -i.bak '/pattern/d' input.txt
Search This Blog
Shell scripting: remove .DS_Store and ._* files recursively on Linux or Mac
find . -name ".DS_Store" -print0 | xargs -0 rm -rf find . -name "._*" -print0 | xargs -0 rm -rf
find . -name ".DS_Store" -delete find . -name "._*" -delete
find . \( -name '.DS_Store' -or -name '._*' \) -delete
Shell scripting: enclose all lines with quotes
- Using awk:
awk '{print "\""$0"\""}' input.txtor if ignore empty lines:awk 'NF {print "\""$0"\""}' input.txt -
Or using sed:
sed -i.bak 's/^/"/; s/$/"/' input.txt
or if ignore empty lines:sed -i.bak 's/^..*$/"&"/' input.txt
Shell Scripting: delete blank lines from a text file using sed
Delete empty lines using sed:
sed -i.bak '/^\s*$/d' 1.txt
Subscribe to:
Posts (Atom)