06-16-2005
I think we misunderstood what the threadstarter wanted: The task is to concatenate all lines starting NOT with a "1" to the last line so that all lines start with a "1" and end with an "e":
source.file:
1 this line is ok E
1 This line starts ok
but continues E
1 here is the next line E
target.file:
1 this line is ok E
1 This line starts ok but continues E
1 here is the next line E
This can easily be accomplished by sed's "N" and "P" subcommands, which reads in the next line and print the whole pattern space respectively.
I could say "man sed", but I'd rather like to suggest reading Dale Doughertys fantastic book "sed & awk" from O'Reilly Publishing. He discusses exactly such cases as examples for setting up what he calls a "while..do loop in a sed-script".
bakunin
9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello,
I have a file that has got carriage returns in it and I want to take them out. Anyone know how I can do this in a ksh?
thanks (4 Replies)
Discussion started by: pitstop
4 Replies
2. Shell Programming and Scripting
:confused: hi all,
i have csv file with three comma separated columns
i/p file
First_Name, Address, Last_Name
XXX, "456 New albany \n newyork, Unitedstates \n 45322-33", YYY\n
ZZZ, "654 rifle park \n toronto, canada \n 43L-w3b", RRR\n
is there any way i can remove \n (newline) from... (10 Replies)
Discussion started by: gowrish
10 Replies
3. Shell Programming and Scripting
Hi all,
I know this is **awfully** general but.....
I have a script which does, basically...
for file in `find command`; do
some stuff
more stuff
echo '.\c'
done
I want to output the '.' char just to give an idea of progress. However, it works fine for a while and then I... (2 Replies)
Discussion started by: ajcannon
2 Replies
4. Shell Programming and Scripting
Hi gurus
I am stripping lots of email addresses from a file with this
grep "^To" file.log |awk '{print "1,"$2}' > recipients.out
file.log looks something like this:
oasndfoasnosf
To: person@email.co.uk
lsdfjosd
sdlfnmsopdfwer
dtlghodrgn
To: person2@emailsss.com
sldfnsdf
I... (5 Replies)
Discussion started by: terry2009
5 Replies
5. UNIX for Dummies Questions & Answers
Hi,
I have a .properties file that a read in some values in an .sh file but everytime I put it out on the server it fails.
If I copy and paste the values of the .properties file on my local machine to the .properties file on the server it works just fine. Someone mentioned to see if it has
dos... (3 Replies)
Discussion started by: vsekvsek
3 Replies
6. Shell Programming and Scripting
I have some data, each record (line) ends with a line feed (\n). Each field is pipe (|) delimited.
1|short desc|long text|2001-01-01 01:01
2|short desc| long
text |2002-02-02 02:02
3|short desc| long text | 2003-03-03 03:03
4|short desc
| long text | 2004-04-04 04:04
... (10 Replies)
Discussion started by: ericdp63
10 Replies
7. Shell Programming and Scripting
Hi everyone,
I'm very new to using sed, run through some tutorials and everything but I've hit a problem that I'm unable to solve by myself.
I need to remove all linefeeds that are followed by a particular character (in this case a semicolon). So basically, all lines starting with a semicolon... (5 Replies)
Discussion started by: fluffdasheep
5 Replies
8. Shell Programming and Scripting
Hi
$ cat ad.sh
ldapsearorg -x -LLL -h sb1131z.testbadbigcorp.org -D "CN=ADMINZZ,OU=AdminRoles,DC=testbadbigcorp,DC=org" -w "UT3w4f57lll--4...4" -b "OU=Test,DC=testbadbigcorp,DC=org" "(&(&(&(&(objectCategory=person)(objectClass=user)(lockoutTime:1.2.840.113556.1.4.804:=4294967295)))))" dn$... (3 Replies)
Discussion started by: slashdotweenie
3 Replies
9. Shell Programming and Scripting
I would like to remove carriage returns/line feeds in a text file, but in a specific cadence:
Read first line (Header Line 1), remove cr/lf at the end (replace it with a space ideally);
Read the next line (Line of Text 2), leave the cr/lf intact;
Read the next line, remove the cr/lf;
Read... (14 Replies)
Discussion started by: tomr2012
14 Replies
COL(1) BSD General Commands Manual COL(1)
NAME
col -- filter reverse line feeds from input
SYNOPSIS
col [-bfhpx] [-l num]
DESCRIPTION
The col utility filters out reverse (and half reverse) line feeds so that the output is in the correct order with only forward and half for-
ward line feeds, and replaces white-space characters with tabs where possible. This can be useful in processing the output of nroff(1) and
tbl(1).
The col utility reads from the standard input and writes to the standard output.
The options are as follows:
-b Do not output any backspaces, printing only the last character written to each column position.
-f Forward half line feeds are permitted (``fine'' mode). Normally characters printed on a half line boundary are printed on the fol-
lowing line.
-h Do not output multiple spaces instead of tabs (default).
-l num Buffer at least num lines in memory. By default, 128 lines are buffered.
-p Force unknown control sequences to be passed through unchanged. Normally, col will filter out any control sequences from the input
other than those recognized and interpreted by itself, which are listed below.
-x Output multiple spaces instead of tabs.
The control sequences for carriage motion that col understands and their decimal values are listed in the following table:
ESC-7 reverse line feed (escape then 7)
ESC-8 half reverse line feed (escape then 8)
ESC-9 half forward line feed (escape then 9)
backspace moves back one column (8); ignored in the first column
carriage return (13)
newline forward line feed (10); also does carriage return
shift in shift to normal character set (15)
shift out shift to alternate character set (14)
space moves forward one column (32)
tab moves forward to next tab stop (9)
vertical tab reverse line feed (11)
All unrecognized control characters and escape sequences are discarded.
The col utility keeps track of the character set as characters are read and makes sure the character set is correct when they are output.
If the input attempts to back up to the last flushed line, col will display a warning message.
ENVIRONMENT
The LANG, LC_ALL and LC_CTYPE environment variables affect the execution of col as described in environ(7).
EXIT STATUS
The col utility exits 0 on success, and >0 if an error occurs.
SEE ALSO
colcrt(1), expand(1), nroff(1), tbl(1)
STANDARDS
The col utility conforms to Version 2 of the Single UNIX Specification (``SUSv2'').
HISTORY
A col command appeared in Version 6 AT&T UNIX.
BSD
August 4, 2004 BSD