linux - How to get specific string from a file and store it in new file in shell script? -


i have 1 sql file contain data in file line follow:

insert a=1 , b=2;   insert a=2 , b=10; 

like many lines there want fetch these lines contain "insert" keyword till semicolon , create new file , save new file.

using shell script.

$ sed -n '/^\s*insert/p' data > newfilename $ cat newfilename  insert a=1 , b=2; insert a=2 , b=10; 

or using grep:

$ grep '^insert' data > newfilename  $ cat newfilename  insert a=1 , b=2; insert a=2 , b=10; 

using awk:

$ awk '/^insert/' data > newfilename $ cat newfilename  insert a=1 , b=2; insert a=2 , b=10; 

Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -