- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: some grepping and seding
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
08-09-2004 12:13 AM
08-09-2004 12:13 AM
some grepping and seding
I have a directory list like this
CD_1.0
REL_3.0
I want a command through which I can just
extract the numerical part if i replace
SUFFIX BEFORE "_"
Thanks
Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2004 12:22 AM
08-09-2004 12:22 AM
Re: some grepping and seding
awk -F "_" '{print $2}'
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2004 12:24 AM
08-09-2004 12:24 AM
Re: some grepping and seding
Is what you are looking for:
# pwd
/abc
# ll
total 0
drwxrwxrwx 2 root sys 96 Aug 9 17:50 CD_1.0
drwxrwxrwx 2 root sys 96 Aug 9 17:52 REL_3.0
# ll | cut -d "_" -f2
total 0
1.0
3.0
#
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2004 12:26 AM
08-09-2004 12:26 AM
Re: some grepping and seding
echo $value|cut -f2 -d"_"
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2004 12:37 AM
08-09-2004 12:37 AM
Re: some grepping and seding
How to get rid of total and and how to
assign this value to a variable.
Thanks
Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2004 12:57 AM
08-09-2004 12:57 AM
Re: some grepping and seding
what about:
VALUE=$( ls | cut -d "_" -f2 )
echo $VALUE
HTH,
Massimo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2004 01:56 AM
08-09-2004 01:56 AM
Re: some grepping and seding
VALUE=$(
To clarify the awk command that someone listed above, you'd need:
ll | awk -F "_" '{print $2}'
or
VALUE=$( ll | awk -F "_" '{print $2}')
Best regards,
Kent M. Ostby
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2004 08:38 PM
08-09-2004 08:38 PM
Re: some grepping and seding
See if this works for you.
#!/usr/bin/ksh
list=`ls | cut -d "_" -f 2`
funct1 $list
funct1()
{
V1=$#
x=1
while true
do
if [ $V1 -gt 0 ]
then
VAR$x=$1
shift
let x=x+1
let V1=V1-1
else
exit
fi
done
}
Hope that helps.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2004 09:19 PM
08-09-2004 09:19 PM
Re: some grepping and seding
# ls
CD_1.0 REL_3.0 test_4.0
# ls | awk -F _ '{ s += $2 } END { print "sum = " s }'
sum = 8
It will give the value. You can assign to a new variable and can be used in operation following this.
And one more ,
your profile says as,
http://forums1.itrc.hp.com/service/forums/publicProfile.do?userId=CA1059455&forumId=1
I have assigned points to 78 of 400 responses to my questions.
It is good to take time to resolve this :)