LinuxQuestions.org
Review your favorite Linux distribution.
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 04-14-2008, 12:37 AM   #1
oskeewow
LQ Newbie
 
Registered: Apr 2008
Location: Greater Chicago
Distribution: Centos, SuSE, RHEL..etc..
Posts: 9

Rep: Reputation: 0
How to suppress "\M" when using echo command


Hello! I have a simple script that reads uuencoded data from myfile and generate separate file for each market. The uuencoded data sometimes end a line with "\" and that causes echo command join two lines into one. How can I suppress the "\" character in $line to be misrepresented as a command? Thank you!

script
---------------------
cat /home/myfile | \
while read line

do
sword=`echo $line | grep Subject | awk '{print $2}'`

if [ $sword ] ; then
market=$sword
else
echo $line >> $market.txt <---problem here
fi
done
---------------------
two lines in myfile..
MD;I9I56^WZ5Y-X<*)`KN=WV(][N:\403GN(GQVKWNQ*>,B3R/-WP0ZROWV]\
MSDV:F_OKT2#3\T_3.KG/8'[.>H!-DBYOO^S#3N-]>?+:L&7+IE_&B54VQH<;

Instead of getting two lines in a new file, one long line is created on the new line.

Last edited by oskeewow; 04-14-2008 at 12:51 AM. Reason: clarify
 
Old 04-14-2008, 01:05 AM   #2
djeikyb
Member
 
Registered: Nov 2005
Location: California
Distribution: ubuntu 10
Posts: 162

Rep: Reputation: 33
Is removing the backslash acceptable?

Code:
$ foo='MD;I9I56^WZ5Y-X<*)`KN=WV(][N:\403GN(GQVKWNQ*>,B3R/-WP0ZROWV]\'
$ echo $foo | sed -e 's/\\$//g'
MD;I9I56^WZ5Y-X<*)`KN=WV(][N:\403GN(GQVKWNQ*>,B3R/-WP0ZROWV]

The dollar sign looks for matches only at the end of a line.

Last edited by djeikyb; 04-14-2008 at 01:09 AM.
 
Old 04-14-2008, 01:22 AM   #3
oskeewow
LQ Newbie
 
Registered: Apr 2008
Location: Greater Chicago
Distribution: Centos, SuSE, RHEL..etc..
Posts: 9

Original Poster
Rep: Reputation: 0
I found a way. I was focusing on the "echo" command. But it was really the "read" command that needed the "-r" option. It suppresses any backslashes in the input as commands. Thanks for your time!
 
Old 04-14-2008, 02:05 AM   #4
djeikyb
Member
 
Registered: Nov 2005
Location: California
Distribution: ubuntu 10
Posts: 162

Rep: Reputation: 33
Nifty! Hopefully I'll remember that when I have a need to learn about the read command.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 11:18 PM
"list dynamic dependency" of an executable using command other than "ldd" Amrita@3086 Solaris / OpenSolaris 3 04-04-2007 05:56 AM
BASH: How to NOT echo to screen with "if echo $x | grep ".*"; then" eur0dad Programming 9 07-27-2006 03:14 PM
Tiny Sofa 2.0 - I thought "halt", "reboot" were only root command ?? sorcerer Linux - Distributions 1 08-21-2004 04:28 PM
"segmentation error" when issuing "useradd" command through terminal with RH 9.0 kaihuang Linux - General 0 10-22-2003 12:47 AM


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

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration