My AWK script will change $2 and $3 based on the value of $1.
The values in $1 are distinct and must match to one of the values in the first column with every call to this script.
So far it works fine.
What I'm wondering how to do is to test if the AWK code successfully completed.
If I call $? I always get a status of 0 (since the cat does work fine).
How do I verify that the AWK code did not error out?
I have to take whatever data is in csv_file.csv (orig. file) and carry it through to the tmp file (tmp_file.csv). I need to move the entire 'file' which consists of many 'records' and only change the data in position 2 and 3 on a match to the data in position 1.
The print outside of the IF statement in the awk code allows all data to pass through to the tmp file, so even when the IF statement fails (awk) I still get a file with all data, but no match.
Was hoping to catch this in the awk statement. Guess I'll need to write more code to catch this type of error earlier.
solaris 5.10 Generic_138888-03 sun4v sparc SUNW,Sun-Fire-T200
I need a sed command that tests true when presented with lines that contain either forward and backslash.
input file:
c:/myFile.txt
c:\yourFile.txt
It doesn't appear that sed (in my environment anyway) supports... (4 Replies)
Hi Guys,
I have an issue with awk and variables. I have trawled the internet and forums but can't seem to get the exactt syntax I need.
I have tried using awk -v and all sorts of variations but I have hit a brick wall. I have spent a full day on this and am just going round in circles.
... (3 Replies)
hello, I require help in the following. There is a report similar to the ones shown here. I need to do couple of things
10/07 12:47 0003210042 R TENN ANVISER0 DELF96A.V1.O.TENRREG 120710 124657 U 00000 DELFOR 1 4331
10/07 12:47 0003210043 S TENN... (2 Replies)
Guys,
I am new in awk , I face problem while i try to use for loop in awk,
I am using ksh, i am trying to set a for loop which runs as man times as the records in a file , the for loop like for(a=1;a<=5;a++) is working in my awk script but the one i need is not working :wall:
for example
... (8 Replies)
Hello all, I'm working on an attendance callout script for a school district. I need to change our current layout for the vendor. Currently the data is in the form of:
studentid,period,building,
Heres a sample of some made up records:
500,1,30,
500,2,30,
500,3,30,
500,6,30,... (7 Replies)
Hello,
Im a beginner. Im writing a ksh script with awk. Is it possible to assign the output of the awk to a shell variable?
Like,
shell_variable= awk '$1 == "shell" {abc= $2 }' /tmp/cust_det
echo $shell_variable
Please excuse my ignorance. Thanks in advance. (4 Replies)
I'm trying to write a ksh script that uses awk, but I want to pass variables to awk. For example (not working):
if ];then
searchstr=$1
lsof -i | awk '{if($9~/SEARCHSTR/) print $2} SEARCHSTR=$searchstr'
else
echo "usage: $0 <search string>"
fi
I tried several options. Is it... (3 Replies)
Hi. I have a kornshell script that runs on a daily basis as a cron job. Part of what the script does is copy the folder contents from another server to the current server (server where KSH script is running).
I have a scp command, as follows:
scp $REMOTE_HOST:$REMOTE_FILE_DIR/* $TMP_DIR
... (8 Replies)