1
vote
1answer
120 views

Recursively change the name of a file and the content inside the file if matches a keyword

I can use sed to do recursively find and replace a string in a bunch of files. Like so: find -name "*.py" -not \( -name .svn -prune \) -type f -print0 | xargs -0 sed -i 's/cat/dog/g' However is ...
-1
votes
3answers
334 views

unix command to remove empty lines in a file

How do I remove empty/blank (including spaces only) lines in a file in Unix/Linux using the command line ? contents of file.txt Line:Text 1:<blank> 2:AAA 3:<blank> 4:BBB 5:<blank> ...
1
vote
1answer
117 views

Mail-merge like operation with sed (or similar)

I would like to perform the following operation: Given a file like this: update FOO set STATUS="X" where ID=<REPLACE>; insert into BAR (Z,W) values(<REPLACE>, 42); And a file like ...
20
votes
3answers
36k views

How to display certain lines from a text file in Linux?

I guess everyone knows the useful Linux cmd line utilities head and tail. Head allows you to print the first X lines of a file, tail does the same but prints the end of the file. What is a good ...