Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


  Search this Thread
Old 10-29-2004, 12:29 AM   #1
Registered: Oct 2004
Distribution: Fedora 7
Posts: 232

Rep: Reputation: 30
Question bash format "cat" output

I'm using the --colorsel option from Xdialog and giving the output to a variable using the "cat" function.
what's happening is the Xdialog program is letting the user select a color.
Then I assigned this to a file using 2>"FILE" then I'm using the cat function to read this file into a variable. Then I echo the variable and....

The output looks like this:
244 122 255

but I need it to look like this:
244, 122, 255

Is there a way to get it to read untill a space is encountered and then assign this a variable, then read untill the next space is encountered....ext...ext....?

anyone know how to do this?
thanks in advance!!

Last edited by bendeco13; 10-29-2004 at 01:09 AM.
Old 10-29-2004, 01:30 AM   #2
LQ Addict
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,891

Rep: Reputation: 351Reputation: 351Reputation: 351Reputation: 351
You could probably pipe the output through either sed or awk to search for <space> and replace that with <comma><space>.
Use google to search for sed and awk examples.
Old 10-29-2004, 01:55 AM   #3
Registered: Oct 2004
Distribution: Fedora 7
Posts: 232

Original Poster
Rep: Reputation: 30
Thanks Alot!!!!
I ended up using awk.
Here's what I had to do:
$DIALOG --rc-file $SKIN --colorsel "Select A Color" 0 0 2>/tmp/checklist-audiotools.tmp.$$
COLOR1a=`awk '{ printf $1 }' /tmp/checklist-audiotools.tmp.$$`
COLOR1b=`awk '{ printf $2 }' /tmp/checklist-audiotools.tmp.$$`
COLOR1c=`awk '{ printf $3 }' /tmp/checklist-audiotools.tmp.$$`
rm -f /tmp/checklist-audiotools.tmp.$$
COLOR1="{ $COLOR1a, $COLOR1b, $COLOR1c}"
Old 10-29-2004, 06:39 AM   #4
Senior Member
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

Rep: Reputation: 47
Look at THIS thread.


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 script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 7 12-19-2015 01:03 AM
bash redirection "$ cat << EOF > file" (how does this work) ninmonkeys Linux - General 1 11-09-2004 03:37 PM
bash equivalence of tcsh "alias em "emacs \!:1 &""? rgiggs Slackware 3 07-29-2004 02:07 AM
bash-2.05b# Xlib: extension "XFree86-DRI" missing on display ":0.0". citrus Linux - General 8 02-22-2004 10:43 AM
"Diff" output format ganninu Linux - General 1 12-09-2003 09:39 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:32 PM.

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