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 10-29-2004, 12:29 AM   #1
bendeco13
Member
 
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
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Squeeze
Posts: 5,784

Rep: Reputation: 311Reputation: 311Reputation: 311Reputation: 311
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
bendeco13
Member
 
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:
Code:
DIALOG=Xdialog
$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
/bin/bash
Senior Member
 
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

Rep: Reputation: 46
Look at THIS thread.
 
  


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 script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 6 03-21-2013 10:35 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


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