Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you invoke unix command within awk

Status
Not open for further replies.

mawk

Technical User
Jun 15, 2003
6
US
I have numerous files that need a fold -80 commmand performed for each file and then output to a new file_name for each file.

I would like to include the fold step within awk with the pipe command and fold options along with some other steps for each file.

Is this possible within the awk script?
 
This may not be the best way to solve your problem but you can pipe the output of fold into getline.

while ("fold ..." | getline) {
...
}

CaKiwi

"I love mankind, it's people I can't stand" - Linus Van Pelt
 
Doesn't sound very practical with getline because of your usage. If all you want is to invoke fold with options and
then redirect the OP to another file I suggest system.

system("fold -80 " ARGV[1] " >" ARGV[2])
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top