LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 03-23-2007, 12:18 AM   #1
Hailey's_Comet
Member
 
Registered: Jul 2005
Location: USA
Distribution: PCLinuxOS
Posts: 36

Rep: Reputation: 18
using 'sed'... **SOLVED**


I am writing a script to allow a user to properly set up a "saa7130/4" tv tuner card, and the only thing I can't figure out is this...

I need to 'cat' a file that has this:

Code:
3
15
23
45
73
92
and put it in the variable $choices for:

Code:
choice=$(kdialog --title "$title" --radiolist "$message" $choices)
but i need it in the form:

Code:
"3" "15" "23" "45" "73" "92"
I wish that I could find an adequate explanation for regexp, but can't. Please explain with response if possible...

Last edited by Hailey's_Comet; 03-27-2007 at 02:35 PM.
 
Old 03-23-2007, 12:40 AM   #2
Jerre Cope
Member
 
Registered: Oct 2003
Location: Texas (central)
Distribution: ubuntu,Slackware,knoppix
Posts: 323

Rep: Reputation: 37
Maybe awk:

cat file | awk '{ printf( "\"%s\"\t",$1)}' | awk '{ print $0}'

I used to pipe things around in sed and awk, now I just use perl. perldocs.org has all you need to get started. All the things you learned about regular expressions in awk and sed will be useful in perl as well.
 
Old 03-23-2007, 02:49 AM   #3
Hailey's_Comet
Member
 
Registered: Jul 2005
Location: USA
Distribution: PCLinuxOS
Posts: 36

Original Poster
Rep: Reputation: 18
could you either explain that regexp, or point me to a good page/site that can?
 
Old 03-23-2007, 03:22 AM   #4
Hailey's_Comet
Member
 
Registered: Jul 2005
Location: USA
Distribution: PCLinuxOS
Posts: 36

Original Poster
Rep: Reputation: 18
Actually, this is exactly what I'm looking for:

cat text | awk '{ printf("\"%s\" ",$1)}' | awk '{ print $0}'

to get:

"3" "23" "33" "73"

and not:

"3" (tab) "23" (tab) "33" (tab) "73"

thank you!
 
Old 03-23-2007, 06:31 AM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
At http://tldp.org:
Bash guide for beginners
Advanced Bash scripting guide

Sed and awk:
http://www.grymoire.com/Unix/
 
Old 03-27-2007, 02:34 PM   #6
Hailey's_Comet
Member
 
Registered: Jul 2005
Location: USA
Distribution: PCLinuxOS
Posts: 36

Original Poster
Rep: Reputation: 18
thanks for the link pixellany, I am going to read it this weekend. Until I can afford some C/C++ books, I am sticking to shell programming. (Not that I mind much, after all I am a DOS wizard, why not bash too?)
 
  


Reply



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
need help with sed Mangenius Linux - Newbie 3 01-22-2007 05:11 PM
bash script with grep and sed: sed getting filenames from grep odysseus.lost Programming 1 07-17-2006 11:36 AM
[sed] "Advanced" sed question(s) G00fy Programming 2 03-20-2006 12:34 AM
sed and escaping & in something like: echo $y | sed 's/&/_/g' prx Programming 7 02-03-2005 11:00 PM
Insert character into a line with sed? & variables in sed? jago25_98 Programming 5 03-11-2004 06:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration