LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 12-29-2004, 04:58 PM   #1
slack guy
LQ Newbie
 
Registered: Dec 2004
Distribution: Slack 10.0
Posts: 3

Rep: Reputation: 0
bash script help to parse out text


this is probably something very simple, but I can't seem to figure out how to do it..

I'm basically looking to parse out a section of text (four letters worth) from a text file and throw it into a variable for further processing in my script.. The text that I want to grab will always come from an exact location on the first line of the text file (20 characters in) and follows the text "s/n ****" in the string. **** is the text that I need to grab from the file.. It'll be a 4 digit string.

I was trying to figure out if I could use SED to do this but nothing seemed clear..

Thanks for the help in advance!
 
Old 12-29-2004, 06:24 PM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
Maybe something like this ..
Code:
cat file.txt |grep -e "s/n"|sed 's/^.\{19\}\(.\{4\}\)\(.*\)/\1/'
 
Old 12-30-2004, 08:15 AM   #3
slack guy
LQ Newbie
 
Registered: Dec 2004
Distribution: Slack 10.0
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks homey. Much appreciated.
 
Old 12-30-2004, 08:42 AM   #4
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
Quote:
Thanks homey. Much appreciated.
Good! I charge extra if you appreciate it.


Just Kidding!
 
  


Reply

Tags
bash, parsing


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
Parse String in a Bash script jimwelc Linux - Newbie 8 11-09-2012 07:47 AM
Bash script text replacement... matthurne Programming 4 06-07-2011 06:46 PM
Change Text-File through bash script arkus Programming 2 12-17-2004 08:48 PM
Bash script - reading from text file twantrd Programming 4 11-24-2004 12:38 AM
Need help with perl/bash script to parse PicBasic file cmfarley19 Programming 13 11-18-2004 05:06 PM


All times are GMT -5. The time now is 04:24 AM.

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