Quantcast
Channel: Active questions tagged bash+awk - Ask Ubuntu
Viewing all articles
Browse latest Browse all 102

Separating Commands in a Script File?

$
0
0

I have an assignment running a series of (n)awk commands in one script file. The key of this script file is to filter out certain lines and records of this original text file here, called students:

Frank       Smith       Engineering  Senior     CJohn        Doe         Marketing    Junior     BNancy       Jones       Engineering  Junior     ABetty       Anderson    Nursing      Sophomore  B   Bob         Johnson     History      Freshman   B   James       Smith       Economics    Senior     A

I have these awk commands in my script file testscript.script.

{print $2, $1, $3, $4, $5}/A$/ {print $1, $2} /!A$/ {print $1, $2}

As of now, when I run nawk -f testscript.script students

For the first few lines of the output I get:

Smith Frank Engineering Senior CDoe John Marketing Junior BJones Nancy Engineering Junior ANancy Jones Anderson Betty Nursing Sophomore BJohnson Bob History Freshman BSmith James Economics Senior AJames Smith

Where as you can see the second command has infused with the first, rather than being separated as desired.

Which leads to my question: How can I separate commands in a shell script, such that each new command has a separate, independent output from others?


Viewing all articles
Browse latest Browse all 102

Trending Articles