LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 01-25-2007, 10:13 AM   #1
xeon123
Member
 
Registered: Sep 2006
Posts: 364

Rep: Reputation: 16
get a substring with a bash command


Hi,

i've a file that has the following content:

<param>1</param>
<param>2</param>
<param>3</param>
...
<param>n</param>

I want to use a bash command that put to the output only the values:
1
2
3
...
n

How is this possible?

Thanks,
Pedro
 
Old 01-25-2007, 10:56 AM   #2
Matir
Moderator
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 118Reputation: 118
Code:
sed 's/^<param>\(.*\)<\/param>$/\1/'
 
Old 01-25-2007, 11:36 AM   #3
xeon123
Member
 
Registered: Sep 2006
Posts: 364

Original Poster
Rep: Reputation: 16
Thanks, for the answer.
And, which bash command should i use to remove the spaces from the beginning of each line?

Thanks,
Pedro
 
Old 01-25-2007, 03:22 PM   #4
ygloo
Member
 
Registered: Aug 2006
Distribution: slack
Posts: 323

Rep: Reputation: 30
sed 's/^ *//g' file
to see output

sed -i.bak 's/^ *//g' file
to edit file in place and make backup
 
Old 01-26-2007, 03:50 AM   #5
xeon123
Member
 
Registered: Sep 2006
Posts: 364

Original Poster
Rep: Reputation: 16
Thanks for the aswner
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bash replace all matches of regex substring in string nickleus Linux - General 3 04-30-2011 11:08 AM
php preg_replace substring of a substring senyahnoj Programming 5 12-08-2006 11:31 AM
Need Help Extracting A Substring eur0dad Linux - General 6 09-21-2006 10:34 PM
to get a substring dimah Programming 1 06-22-2006 06:31 AM
bash: <command name> command not found smash Programming 5 03-13-2006 08:48 AM


All times are GMT -5. The time now is 06:45 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