HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: unix script problem
Operating System - HP-UX
1834915
Members
2576
Online
110071
Solutions
Forums
Categories
Company
Local Language
back
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
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
10-26-2003 12:48 PM
10-26-2003 12:48 PM
unix script problem
Hi,
I have written the scrip and using the below command:
ls -1 | awk '{print $NF}' | cut -f1 -d'.' | grep -v '_[0-9]' | sort -u
this gets all the files till the period and than ignores them if they have " _[0-9] " its working ok but I find out that its not getting only one file with the name "nwit00_1400.Oct21"
because this file got " 00 " before " _1400"
what I think is above command first gets the filename till period so it will be "nwit00_1400" than ignores the files with "_1400" (underscore and nubmers) but its ignoring this file altogether can someone help me, what should I do so I can get all the files including this one.
thanks
I have written the scrip and using the below command:
ls -1 | awk '{print $NF}' | cut -f1 -d'.' | grep -v '_[0-9]' | sort -u
this gets all the files till the period and than ignores them if they have " _[0-9] " its working ok but I find out that its not getting only one file with the name "nwit00_1400.Oct21"
because this file got " 00 " before " _1400"
what I think is above command first gets the filename till period so it will be "nwit00_1400" than ignores the files with "_1400" (underscore and nubmers) but its ignoring this file altogether can someone help me, what should I do so I can get all the files including this one.
thanks
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2003 04:52 PM
10-26-2003 04:52 PM
Re: unix script problem
Please revert with the list of files too and what you need
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2003 05:25 PM
10-26-2003 05:25 PM
Re: unix script problem
actually the grep will match lines not contain an underscore followed by a digit.
but it doing just what it is supposed to do.
just an ls would do the same as ls -1 for you. and with only one filename per line, using awk to print the only field is unnecessary.
ls | cut -f1 -d'.' | grep -v '_[0-9]' | sort -u
would do just the same for you. and
ls | awk -F'.' { if ( $1 !~ /_[0-9]/ ) print $1;}' | sort -u
is a bit faster
hard to give advice on how to help you without knowing what's your data and what your expected output should be
but it doing just what it is supposed to do.
just an ls would do the same as ls -1 for you. and with only one filename per line, using awk to print the only field is unnecessary.
ls | cut -f1 -d'.' | grep -v '_[0-9]' | sort -u
would do just the same for you. and
ls | awk -F'.' { if ( $1 !~ /_[0-9]/ ) print $1;}' | sort -u
is a bit faster
hard to give advice on how to help you without knowing what's your data and what your expected output should be
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP