OK. If you really want to get rid of blank lines (lines containing zero or more space and/or tab characters terminated by a newline character) rather than empty lines (lines that only contain the terminating newline character), there are still LOTS of ways to do it. Two are:
where the characters between the square brackets are <circumflex>, <space>, and <tab>. or with sed instead of grep:
where the characters between the square brackets are just <space>, and <tab>.
This User Gave Thanks to Don Cragun For This Post:
This is really weird...I modified my sed expression:
I tried adding the -E but I got a lot of error messages - not sure why that was included. So most of the whitespaces are gone...there used to be 5 whitespaces, now there is 1. So based on this information I have to assume there's something freaky going on with my input file?
---------- Post updated at 03:10 PM ---------- Previous update was at 03:09 PM ----------
Close, but I'm still getting some whitespaces. Possibly an issue with the input file? Anyway I can view special, hidden chars?
More than likely because what the code does is if there is no fields it is skipped.
Last edited by methyl; 08-19-2012 at 06:53 PM..
Reason: fix code tag
@MaintdotC
Yet again, please post what Operating System and version you are running. This really matters - expecially if it happens to be MACOS or Cygwin.
Please post sample input data using this sed command which is designed to make control codes visible and make white space visible. In your case, the line terminators could be important.
Please then post sample expected output data to match you sample input data, with an expanation of the process if it is not obvious.
Footnote: Please explain what you think your sed command does? Where did you find pipe characters in unix group file? What is SEARCHSTRING for? Why "\r\n" (looks like trying to convert to MSDOS format to me)?
Others have posted valid commands to remove white space.
The script posted contains fundamental design issues which we can address once we see the sample data.
The sed command you listed does produce some slashes between the text of the input used for my script but for some reason I am now receiving the desired output. I didn't make a backup of my script and accidentally removed it, so when I wrote it again this morning I didn't even put in a sed expression to remove whitespaces and it works for some reason. Not sure what happened between last night and today but I'm good now - thanks all for your support.
Hi All
Need Help
I have a file with the below format (ABC.TXT) :
®¿¿ABCDHEJJSJJ|XCBJSKK01|M|7348974982790
HDFLJDKJSKJ|KJALKSD02|M|7378439274898
KJHSAJKHHJJ|LJDSAJKK03|F|9898982039999
(cont......)
I need to write a script where it will check for : blank lines (between rows,before... (6 Replies)
Hi,
my input file is like this I want to remove the blank line.
"/home/rit/sandbox/garuda/data/test/woman/T_RITK_F0008_ML_100080039.lab"
r
a
N
e
l
a
k
sh
a
m
.
"/home/rit/sandbox/garuda/data/test/woman/T_RITK_F0008_ML_100070453.lab"
a
v
a
s (4 Replies)
Hi All,
How do i remove continuos blank lines from a file.
I have a file with data:
abc;
def;
ghi;
jkl;
mno;
pqr;
In the above file, there are two blank lines. I want to remove, one out of them.
My output should look like: (2 Replies)
Hi,
Consider a file named "testfile"
The contents of file are as below
first line added for test
second line added for test
third line added for test
fourth line added for test
fifth line added for test (5 Replies)
Hi Guru's , I have a whole bunch of files in /var/tmp that i need to strip any blank lines from, so ive written the following script to identify the lines (which works perfectly).. but i wanted to know, how can I actually strip the identified lines from the actual source files ??
my... (11 Replies)
Hi
i have the below lines from a file
7538
PRGRP450800PERSONAL SOAP AND BATH ADDITIV 7036
PRGRP450800PERSONAL SOAP AND BATH ADDITIV 7036
PRGRP450800PERSONAL SOAP AND BATH ADDITIV 7036... (3 Replies)