ข้ามไปที่เนื้อหาหลัก

Shell scripts to add space in the blank lines to text file

 Awk is a scripting language used for manipulating data and generating reports.The awk command programming language requires no compiling, and allows the user to use variables, numeric functions, string functions, and logical operators. 

Awk is a utility that enables a programmer to write tiny but effective programs in the form of statements that define text patterns that are to be searched for in each line of a document and the action that is to be taken when a match is found within a line. Awk is mostly used for pattern scanning and processing. It searches one or more files to see if they contain lines that matches with the specified patterns and then performs the associated actions. 

Awk is abbreviated from the names of the developers – Aho, Weinberger, and Kernighan. 


AWK Operations: 

(a) Scans a file line by line 
(b) Splits each input line into fields 
(c) Compares input line/fields to pattern 
(d) Performs action(s) on matched lines 


Syntax: 
 

awk options 'selection _criteria {action }' input-file > output-file

Options: 
 

-f program-file : Reads the AWK program source from the file 
                  program-file, instead of from the 
                  first command line argument.

examples:

cp $dest/$file_name $dest/$file_name.tmp1


awk '!NF{$0=" "}1' $dest/$file_name.tmp1 > $dest/$file_name 


rm -f $dest/$file_name.tmp1