Re: trying to script a command line

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Craig White
Date:  
To: Main PLUG discussion list
Subject: Re: trying to script a command line
OK - truly simplifying my issue to a point where someone should be able
to explain this to me...

# my starting file
$ cat test-db.txt
A 1
B 2
C 3

# this is what I want
$ cat test-db.txt | cat test-db.txt | sed 's/ /\\ /g' | sed ':a;N;$!
ba;s/\n/ /g'
A\ 1 B\ 2 C\ 3

# but if I aggregate the command inside backticks, I lose the
# escaped spaces part of the sed command...

$ TEST=`cat test-db.txt \
| cat test-db.txt \
| sed 's/ /\\ /g' \
| sed ':a;N;$!ba;s/\n/ /g'`


$ echo $TEST
A 1 B 2 C 3

So the carriage returns are removed by the spaces aren't escaped.

How can I do this so I can aggregate a file with fields on each line so
that the carriage returns are removed and the spaces are escaped?

Craig

---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change your mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss