1830997 Members
2535 Online
110018 Solutions
New Discussion

script help

 
SOLVED
Go to solution
roger_114
Occasional Contributor

script help

I have a file that contains records like this record/:

8,388,616,192 B 02/13/05 12:18:23 /u37/oradata/PRODODS/clm_hdr_dt06.dbf 03/20/05

What is the easiest way to retrieve just the full file name out these records?
(in this record , I only need /u37/oradata/PRODODS/clm_hdr_dt06.dbf)

Thanks

5 REPLIES 5
Chris Vail
Honored Contributor
Solution

Re: script help

I've counted only 3 spaces in the line you posted. Therefore awk '{ print $3 }' $FILE would return the 3rd field--the data you're looking for.


Chris
A. Clay Stephenson
Acclaimed Contributor

Re: script help

If yoiu need to do some processing:

INFILE="xxx/yyy.txt"
cat ${INFILE} | awk '{print $(NF -1)}' | while read FNAME
do
echo "${FNAME}"
done

The simplest:
awk '{print $(NF -1}}' xxx/yyy.txt
If it ain't broke, I can fix that.
Rodney Hills
Honored Contributor

Re: script help

data="8,388,... /u37/oradata/..."
file=${data##* }

HTH

-- Rod Hills
There be dragons...
Robert Bennett_3
Respected Contributor

Re: script help

Try this:

cat | awk -F \ '{print $4}'

This should give you the part you need.
"All there is to thinking is seeing something noticeable which makes you see something you weren't noticing which makes you see something that isn't even visible." - Norman Maclean
Rodney Hills
Honored Contributor

Re: script help

Oops. Ignore my previous suggestion. I thought the filename was the last field on the line.

You could use-
awk '{print $5}' inputfile
or
cut -f5-5 inputfile

HTH

-- Rod Hills
There be dragons...