라벨이 sed인 게시물 표시

delete specific line from a file in linux

1. n: the number of line sed 'nd' filename (just print) sed -i 'nd' filename (change file) 2. word: the word contained in line which I want to delete sed '/word/d' filename (just print) sed -i '/word/d/ filename (change file) Thanks, JF

Linux example of sed

* sed: Stream EDitor 1. search and print sed -n 'asdf/p' file : Read file line by line without print (-n), and print a line if asdf is found. 2. substitution sed 's/asdf/qwer/' file : replace asdf by qwer, and does not change original file. just print sed 's/asdf/qwer/' file > copyfile : replace asdf by qwer, and copy file to copyfile sed -i 's/asdf/qwer/' file : replace asdf by qwer and change original file If you would like to do for entire file, using '/g'. sed -i 's/asdf/qwer/g' file : replace asdf by qwer for entire file, and change original file Thanks, JF

Delete a line including a word in a file using sed in Linux

If you want to delete a line including 'Fast' in a file 'abc.txt', do this >> sed /Fast/d abc.txt Below is example. >> cat abc.txt abc abc abc abc Fast abc >> sed /Fast/d abc.txt abc abc abc abc abc Thanks, JF

Replacing words within files in linux (find, sed)

이미지
Hi. When you want to replace words in files, do like this! 1. Find files having words you want to replace 2. Change it ! Here is example! I want to replace all "Fe" to "Mo" at all POSCAR files. Thanks, Jin-Myoung Lim