- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- removing the last character from fuser
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
тАО10-26-2007 01:36 AM
тАО10-26-2007 01:36 AM
I am working on AIX and run fuser, I get several procs with 1234c 234344c 34445c
how can I script to loose the last character, I'd like to know how to drop any final character for otheer scripting purposes.
Thanks for your help!
Chris.
Solved! Go to Solution.
- Tags:
- fuser
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2007 01:53 AM
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2007 01:56 AM
тАО10-26-2007 01:56 AM
Re: removing the last character from fuser
fuser -c /data 2>&1 | sed -e 's/[a-z]//g' -e 's/[^0-9[:blank:]]//g'
Jeff Traigle
- Tags:
- sed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2007 02:05 AM
тАО10-26-2007 02:05 AM
Re: removing the last character from fuser
Simply redirect stderr to /dev/null.
This strips everything apart from the PIDs.
e.g.
# fuser -c /oracle 2>/dev/null
15385 15488 15392 15487 15405 15388 15407 12205 15418 15406 15410 15420
15372 2676 15404 15386
This is handy if you want to use the PIDs in situ.
# ps -p "$(fuser -c /oracle 2>/dev/null)"
ps: wrong PID number
PID TTY TIME COMMAND
15385 ? 430:55 disp+work
15488 ? 533:41 jlaunch
15392 ? 11:15 disp+work
15487 ? 84:04 jlaunch
15405 ? 0:05 disp+work
15388 ? 595:17 disp+work
15407 ? 0:03 disp+work
12205 ? 3:39 disp+work
15418 ? 6:15 disp+work
15406 ? 0:00 disp+work
15410 ? 0:00 disp+work
15420 ? 0:00 disp+work
15372 ? 7:00 disp+work
2676 ? 0:00 disp+work
15404 ? 1:35 disp+work
15386 ? 49:07 disp+work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2007 02:06 AM
тАО10-26-2007 02:06 AM
Re: removing the last character from fuser
Jeff Traigle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2007 02:25 AM
тАО10-26-2007 02:25 AM
Re: removing the last character from fuser
Thanks, Ralph, I too remembered that when I actually executed 'fuser'.
By the way, Chris, Perl allows a negative value for the length parameter to 'substr'. Using a negative value for length trims that many characters from the end. For example:
# echo abc123|perl -nle 'print substr($_,0,-1)'
abc12
Thus, there's yet another way to do this.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2007 03:23 AM
тАО10-26-2007 03:23 AM
Re: removing the last character from fuser
as always plenty of ways of killing a bird with many stones!
:-)
Chris.