- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- awk parsing
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
Forums
Discussions
Discussions
Discussions
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
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-19-2004 06:12 AM
03-19-2004 06:12 AM
I got a list of file like this:
mcdbq/ABCDGEF.P
crtbn/GIFGEO.I
djgei/DKJFEO.VAR
rtbkdjf/fjiefj.p
rgmien/fjeijg.i
rteji/fjeij.d
The .P can be whatever as long as it's in capital. I am trying to get a listing of the files in capital only using this command:
tar -tvf filename.tar |awk -v file="[A-Z]*\.[A-Z]*$" '{if($8 ~ file)print $8'
It prints all the files (including the non-capital file); but if I do this:
tar -tvf filename.tar |awk -v file="[A-Z]*\.P*$" '{if($8 ~ file)print $8'
it only prints the .P file, which is not all the file I want
I even use this command:
tar -tvf filename.tar |awk -FS="/" -v file="[A-Z]*\.[A-Z]*$" '{if($8 ~ file)print $8'
and there is no output at all. Where did I got wrong? Any help is appreciate.
Thi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2004 06:27 AM
03-19-2004 06:27 AM
Re: awk parsing
tar -tvf filename.tar | grep -e "[A-Z]\$"
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2004 06:31 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2004 06:38 AM
03-19-2004 06:38 AM
Re: awk parsing
tar -tvf filename.tar |awk -v file="\.[A-Z]+$" '{if($8 ~ file)print $8'
use a + instead of *
* matches zero or more, as in it doesn't have to be there
+ matches one or more, there has to be at least one.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2004 06:56 AM
03-19-2004 06:56 AM
Re: awk parsing
Your commands show everything (small letter files and capital letter files)
Hein,
Your command work, however thinking further down at the script I would like to know how do I go about if I want this:
I have: mcstm/ABDEGD.P
I would like to assign file=ADBEGD.P and
dir=mcstm where I will call the variable file and dir several times somewhere else in the script. Thanks
Thi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2004 07:01 AM
03-19-2004 07:01 AM
Re: awk parsing
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2004 07:35 AM
03-19-2004 07:35 AM
Re: awk parsing
Make the following change (double quotes to single and an extra "\")-
tar -tvf filename.tar |awk -v file='[A-Z]*\\.[A-Z]*$' '{if($8 ~ file)print $8'
HTH
-- Rod Hills
tar -tvf filename.tar |awk -v file="[A-Z]*\.[A-Z]*$" '{if($8 ~ file)print $8'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2004 08:01 AM
03-19-2004 08:01 AM
Re: awk parsing
tar -tvf filename.tar | awk -v file="\.[A-Z]+$" '{if($8 ~ file)print $8}' | while read FILE; do set file=`basename $FILE`;set dir= `dirname $FILE`;done;
Is that what you were looking for?
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2004 08:26 AM
03-19-2004 08:26 AM
Re: awk parsing
> Your command work, however thinking further down at the script
In the awk script or in a shell script that is using n awk command? Check out Micheals example of how to get awk output in a symbol.
In my example the symbols ar ether within the awk script for further processing.
Here are some more samples:
awk:
tar -tvf | awk '{if (match($8,/\/[A-Z\.]+$/)){ dir=substr($8,0,RSTART-1); file=substr($8,RSTART+1,999); print dir,file}}'
perl:
tar -tvf | 'if (/\s(.*)\/([A-Z\.]+)$/) { print "dir=$1, file=$2\n"}'
Hein.