LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > AIX
User Name
Password
AIX This forum is for the discussion of IBM AIX.
eserver and other IBM related questions are also on topic.

Notices

Reply
 
Search this Thread
Old 06-04-2014, 04:35 AM   #1
fritz001
Member
 
Registered: Aug 2004
Posts: 122

Rep: Reputation: 18
Exclamation sed on AIX and HP-UX


Hello all,

I'm facing this issue in my attempt to use sed to extract a variable number from a string

I do have something like this:

file_fruxt0000006_5300-12_20140601152
file_fruxt0000036_6100-12_20140601


I'd like to extract the last number from the string
 
Old 06-04-2014, 05:01 AM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,506

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
Does
Code:
echo file_fruxt0000006_5300-12_20140601152 | sed 's/.*_//'
give the desired result?
 
Old 06-04-2014, 05:10 AM   #3
fritz001
Member
 
Registered: Aug 2004
Posts: 122

Original Poster
Rep: Reputation: 18
Quote:
Originally Posted by colucix View Post
Does
Code:
echo file_fruxt0000006_5300-12_20140601152 | sed 's/.*_//'
give the desired result?
Yes, thanks

meantime I realized I can use awk -F_ '{print $NF}'
 
Old 06-05-2014, 04:07 AM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 1,789

Rep: Reputation: 497Reputation: 497Reputation: 497Reputation: 497Reputation: 497
Or just:
Code:
X='file_fruxt0000006_5300-12_20140601152'; echo "${X##*_}"
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Java on AIX: Data Collection For AIX Core Dumps LXer Syndicated Linux News 0 05-17-2007 06:46 PM
SED command doesn't works fine on AIX JSnake AIX 4 07-01-2004 12:32 PM


All times are GMT -5. The time now is 03:59 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration