The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Bash Scripting keyvan Shell Programming and Scripting 3 05-23-2007 02:04 PM
Bash scripting doubt xiphias Shell Programming and Scripting 2 04-29-2007 08:02 AM
Help!! bash shell scripting.. Fr0z3n999 Shell Programming and Scripting 1 12-07-2006 04:08 PM
bash shell scripting azazalis Shell Programming and Scripting 4 07-11-2006 04:22 PM
Newbie - Need help in bash scripting coolbib Shell Programming and Scripting 4 08-11-2002 09:28 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 07-05-2007
retrovertigo retrovertigo is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 6
Bash scripting question re: newlines

I'm writing a bash script to search the contents of a postfix log. To keep the script's output readable (since multiple lines from the log file need to be echo'ed) I am setting the IFS variable to an empty string so that the line breaks in my grep results are preserved. I am storing the results to a variable. Later in the script, I want to search the entire output as a single line of text. I am not sure if it is possible to make sed consider the results in this variable as a single line, so I am trying to simply remove all the line breaks using the following:


Code:
str1=${results//\n/}

However, it is not working. Does anyone have an idea what I'm doing wrong? The reason that I am trying to search the results as a single line is because I'm looping through all the lines in the search results, searching for a pattern that occurs multiple times. Each time a match is found, I do some further processing. However, if I just run the search results through sed, I get a list of every match. I'd like to be able to process each line separately if possible, but since I haven't been able to figure out how to do that I was trying to treat it as one long line and just parse through it from beginning to end.

If anyone has a better idea on how to do this, I'm open to suggestions. I'm intermediate when it comes to shell scripting, but by no means an expert like so much of you here.
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:03 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0