I need to simplify this a bit I think. What I am really trying to do is print information from the lines above when "No" is matched as the 6th entry in the line that has "Fibre" in it. So when No is matched on $6 I want to print the
Where the line that contains the word "Fibre" looks like
So from the extract of the file that I posted I can easily filter out the "Fibre" and "No" using something like the following command
which prints $1 from that line and obviously I can print anything I want from that line. But when I get a "No" in $6 I want to be able to print the
from the lines just above the line with the "No".
I am really just struggling with trying to filter out data that is in lines above the matched text with "No" in $6.
Once I filer it out I won't have a problem with formatting the output the way I want it.
---------- Post updated at 05:34 PM ---------- Previous update was at 11:59 AM ----------
I have figured out a way around this. I reformatted the file so that I could filter out what I need. It gives me what I need for now. I would still like to know a way to print previous lines in a file when a field entry is matched on a later line. Anyway this is the awk code I used. Not very pretty but it works...
Which generates output like
Last edited by Don Cragun; 06-28-2013 at 08:23 AM..
Reason: Use CODE tags; not QUOTE tags for code and I/O samples
hi,
I am trying to find the word "root" from the follwoing sample file:
#12.12.12.2222
echo "Hai........"
11.11.1.1111
3.23.AS.AA
ab.cd.df.rf
/usr/bin
jhhh 12.12.AF.12
/urf/sss/kk kkk
su sh.s
exec su
root;
,root
sudo -sh
cosrootex (3 Replies)
# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
How would i write a script to display permission on each folders in $PATH variable below format.
drwxr-xr-x 2 0 root 4096 Nov 24 14:51 /usr/kerberos/sbin
drwxr-xr-x 2 0... (2 Replies)
Hi;
i m running an command like;
getfacl $(find /home/fstl/testShell/ -type f -ls | awk '{print $11}')
and i m getting outpiut for all files in "testShell" folder as;
# file: home/fstl/testShell/.script1.sh.swp
# owner: root
# group: root
user:fstl:rw-
user:ajay:rw-
group:root:r--... (1 Reply)
:oi was trying to write a script to format output of a command in ksh which has output as below:
so i used :
to get
which i require at all times. But problem occurs when status part changes. above output i get when status is SU (success).If the status is IN (inactive), output of... (1 Reply)
Hello,
it would be great if someone can help me with the following:
I want to search for the rows from fileA in column 1 of fileB and output column 2 of fileB if found in fileC. In the moment I search within the complete file. How can I change the code so only column 1 is searched?
cat fileA... (7 Replies)
Hi Experts,
- Getting error while using it through a variable to get the PID,
PID=42
# UNIX95=1 ps -e -o pcpu,pid,ppid,stime,etime,args | awk '{if ($2~"^42$") print $0}'
0.00 42 0 Feb 10 600-17:21:29 nfs_async_io
- But when using with a variable it is not working .
#... (6 Replies)
When i execute the below shell script with 2 different Input files, for one of the data files (datafile1) my email message body in the outlook messes up and every thing comes up in one line. May i please know what i am doing wrong here or how to fix this? The only difference in data files is one is... (1 Reply)
Hi Team(Solaris 5.8/Ksh),
How can we save grep output to awk variable when grep returns more than one line or word.
abc.log
# more abc.log
Hi Makarand
How r u
bye Makarand
Hello
when grep returns only 1 word below command works
nawk -v var=`cat abc.log |grep "Hello"` 'BEGIN { if... (6 Replies)