- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: awk command
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-30-2004 04:39 AM
тАО03-30-2004 04:39 AM
awk command
Can someone tell me where this command go wrong:
I have 2 files:
file1: looks like this:
cfxfund/custom/AGUPDAT1.P
rtb_dbup/
rtb_dbup/21862188/
rtb_dbup/21862188/schctrl
rtb_idat/
rtb_idat/compath
rtb_idat/objctrl
rtb_idat/delctrl
rtb_idat/selcomp
rtb_inst/
rtb_inst/v7begin.i
rtb_inst/v7end.i
rtb_inst/objcomp.p
rtb_inst/schupd.p
rtb_inst/schupdp2.p
and in file2, I have almost the same:
cfxfund/custom/ESGACCTINFO.P
cfxfund/custom/ESGCONVFUNC.I
cfxfund/custom/RESPTRS0.P
cfxfund/custom/SAXSIN00.P
cfxfund/custom/SAXSIN01.I
rtb_dbup/
rtb_dbup/21862187/
rtb_dbup/21862187/schctrl
rtb_idat/
rtb_idat/compath
rtb_idat/objctrl
rtb_idat/delctrl
rtb_idat/selcomp
rtb_inst/
rtb_inst/v7begin.i
rtb_inst/v7end.i
rtb_inst/objcomp.p
rtb_inst/schupd.p
rtb_inst/schupdp2.p
Now, when I run this awk command:
cat filename | awk '{n=split($0,p,"/");file=p[n]; if(match(file,"[aA-zZ]*\.[aA-zZ]+")) {print
file}}' > resultfilename
I got 2 different results:
result1 (from file1):
AGUPDAT1.P
v7begin.i
v7end.i
objcomp.p
schupd.p
schupdp2.p
and result2 (from file2):
ESGACCTINFO.P
ESGCONVFUNC.I
RESPTRS0.P
SAXSIN00.P
SAXSIN01.I
I had run this command 2 or 3 times for each file and the result are the same for each file. Can someone point out why or how I can have different results when both files are almost identical? Any help is appreciate. Thanks
Thi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-30-2004 04:55 AM
тАО03-30-2004 04:55 AM
Re: awk command
And the difference in results you spot it that lack of v7begin.i in the second output right?
Well, cutting and pasting your data from the forum and executing the command _does_ those those also for the second group.
So I speculate that you have spaces or such in the files confusing the data? Try cut & paste yourself? If you still have trouble, please ATTACH a file [Browse...] with the exact input files for testing.
btw... I believe the following command will alsso do what you want:
awk -F/ '/\.[aA-zZ]+$/{ print $NF}' < filename > resultfilename
hth,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-30-2004 04:57 AM
тАО03-30-2004 04:57 AM
Re: awk command
To do so, I suggest you use sed :
sed 's+.*/++' $FILENAME | grep -v '^$'
On my box, your awk script do just fine if I use nawk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-30-2004 05:04 AM
тАО03-30-2004 05:04 AM
Re: awk command
for LINE in `cat file1`; do
basename $LINE
done
and redirect the output from the 2nd line to a file if you wanted.
There's also a corresponding command, dirname, that returns the directory path.
mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-30-2004 05:16 AM
тАО03-30-2004 05:16 AM
Re: awk command
rc:temp/script6 $ awk -f useme.awk < file1
AGUPDAT1.P
v7begin.i
v7end.i
objcomp.p
schupd.p
schupdp2.p
awk -f useme.awk < file2
ESGACCTINFO.P
ESGCONVFUNC.I
RESPTRS0.P
SAXSIN00.P
SAXSIN01.I
v7begin.i
v7end.i
objcomp.p
schupd.p
schupdp2.p
That's with /usr/bin/awk.
/usr/bin/awk:
$Revision: 78.14.1.16 $
PATCH_10_20: awk.g.o awk.lx.o b.o main.o tran.o lib.o run.o parse.o pro
ctab.o hpux_rel.o 99/12/17
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-30-2004 05:20 AM
тАО03-30-2004 05:20 AM
Re: awk command
Hein, thanks for the tips. I got the problem solve - it was the space issue. Thank you everyone for the quick reply.
Thi