9thTee
asked on
Need script to test text file
Hi,
I need a script to test a text file and based on the character it finds on line 1 column 60, run different programs. The script can be awk, perl or whatever else that will run on IBM AIX.
If line 1 column 60 is "O" then run program qu
If line 1 column 60 is "d" then run program ak
if line 1 column 60 is "k" then run program pk
If line 1 column 60 is "a" then run program wt
If line 1 column 60 is anything else, run program other
Any help would be appreciated.
Thanks,
Mark
I need a script to test a text file and based on the character it finds on line 1 column 60, run different programs. The script can be awk, perl or whatever else that will run on IBM AIX.
If line 1 column 60 is "O" then run program qu
If line 1 column 60 is "d" then run program ak
if line 1 column 60 is "k" then run program pk
If line 1 column 60 is "a" then run program wt
If line 1 column 60 is anything else, run program other
Any help would be appreciated.
Thanks,
Mark
switch (`head -1 textfile.txt | cut -c 60-60`)
case "O": qu; break;
case "d": ak; break;
case "k": pk; break;
case "a": wt; break;
default: other;
}
case "O": qu; break;
case "d": ak; break;
case "k": pk; break;
case "a": wt; break;
default: other;
}
ASKER
pkwan:
When I run this it says:
Syntax Error The source line is 2.
The error context is
switch >>> (` <<<
awk: 0602-502 The statement cannot be correctly parsed. The source line is 2.
Syntax Error The source line is 3.
Any ideas?
When I run this it says:
Syntax Error The source line is 2.
The error context is
switch >>> (` <<<
awk: 0602-502 The statement cannot be correctly parsed. The source line is 2.
Syntax Error The source line is 3.
Any ideas?
ASKER
brettmjohnson:
I am not sure how to run your script.
Mark
I am not sure how to run your script.
Mark
nevermind, brain burp on my part. The only interesting part is
`head -1 textfile.txt | cut -c 60-60`
which returns the specific character of interest.
The switch statement is from the previous post
and is in awk/C syntax, not Bourne shell syntax.
`head -1 textfile.txt | cut -c 60-60`
which returns the specific character of interest.
The switch statement is from the previous post
and is in awk/C syntax, not Bourne shell syntax.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi SysProg,
What does the L:1 do? I had to remove it for the script to run.
Thanks,
Mark
What does the L:1 do? I had to remove it for the script to run.
Thanks,
Mark
-L means how many characters to consider
By default, it takes upto the end of line
-c means the start position from where u want to cut the string
Amit
By default, it takes upto the end of line
-c means the start position from where u want to cut the string
Amit
ASKER
SysProg,
Well the script works fine without it on IBM AIX. Thanks for the help.
Mark
Well the script works fine without it on IBM AIX. Thanks for the help.
Mark
switch (substr($0, 60, 1)) {
case "O": qu; break;
case "d": ak; break;
case "k": pk; break;
case "a": wt; break;
default: other;
}
}'