Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

bash: improve your command line & script productivity

sed

that edit you're making with vi? try using sed

sed -e 's|find|replace|' ./filename.txt # changed file to stdout

sed -e 's|David Bowman:|Dave:|' \
    -e 's|HAL 9000:|HAL:|' \
    -i ./pod-bay-doors.txt              # no output shown,
                                        # file is modified in place
                                        # use -i.bak to save a backup

inserting content

sed -e '/This mission/a **new line here***' ./pod-bay-doors.txt

sed -e '/This mission/r ./two-lines.txt' ./pod-bay-doors.txt