- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How to parse out fields using awk?
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
тАО06-14-2004 02:15 AM
тАО06-14-2004 02:15 AM
Re: How to parse out fields using awk?
I saw your first post but the second one diverted me:
***************
Mark: I'm using the 'find' command to locate the file so it returns the fullpath.
***************
No points for me....
Best regards,
Ettore
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-15-2004 12:31 AM
тАО06-15-2004 12:31 AM
Re: How to parse out fields using awk?
find /mydir -print | xargs basename?
NO. THAT won't work.
How about...
find /mydir | awk -F/ '// {print $NF}'
Yep. That looks right. I saw the awk command in the forums above.
But if you are looking for the base name perhaps you are just looking for the file?
If that's the case....."I want to find a file that begins with "billy".
find /mydir -name "billy*" -print | awk -F/ '// {print $NF}'
In awk the -F/ is means separate the fields by the / character.
The $NF means the current number of fields on that line.
So print $NF means print the last field on the line.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-15-2004 12:52 AM
тАО06-15-2004 12:52 AM
Re: How to parse out fields using awk?
find /somewhere | while read
do
echo ${REPLY##*/}
done
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-15-2004 01:11 AM
тАО06-15-2004 01:11 AM
Re: How to parse out fields using awk?
Modify to your liking
Enjoy, Have FUN! H.Merijn
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-15-2004 01:50 AM
тАО06-15-2004 01:50 AM
Re: How to parse out fields using awk?
If the variable is stored in variable "fn", try this:
echo ${fn##*/}
and it should show you just the file name.
The "##" removes the large left pattern.
The "*/" is the pattern to be removed.
Tom
- Tags:
- variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-18-2004 09:32 PM
тАО06-18-2004 09:32 PM
Re: How to parse out fields using awk?
You can get the directory name and pathname of all regular files using,
#!/usr/bin/ksh
echo " DIR-NAME FILE-NAME"
find / -type f | while read file; do
echo "`dirname $file` `basename $file`"
done
For other files like character files,block devices change the -type X value from man find
Regards,
Muthukumar.
- « Previous
-
- 1
- 2
- Next »