bjs@reef.cis.ufl.edu (Brian J. Smith) (11/30/90)
When TFM fails, when all the books I have fail, I run to netland. I have searched high and low for the answer on how to strip a NEWLINE charactor from a file. Well not really a NEWLINE char, but a ":\\\n" (colon,back-slash,newline). I have tried useing sed with: sed 's/:\\\n//' file and using the RS variable in awk, but to no avail. sed will remove the colon and the back-slash, but not the newline. Here is the section of code that I am playing with. # ps301d|bigps|qms|QMS-2210 in E301D:\ :lp=/dev/ttyb:sd=/var/spool/ps301d:\ :af=/var/adm/ps301d.acct:lf=/var/spool/ps301d/errs:\ :br#9600:rw:fc#0000374:fs#0000003:xc#0:xs#0040040:\ :mx#0:rg=printer:sf:sh:\ :if=/local/lib/ps/psif:of=/local/lib/ps/psof:\ :cf=/cis/reef/wp42/bin/wplpr:df=/local/lib/ps/psdf:\ :gf=/local/lib/ps/psgf:nf=/local/lib/ps/psnf:\ :rf=/local/lib/ps/psrf:tf=/local/lib/ps/pstf:\ :vf=/local/lib/ps/psvf: # This is what I want the file to look like after the (colon,back-slash,newline) has been striped. As you can see what I really want is to strip a (colon,back-slash,newline,tab), but if someone could just get rid of that darn newline for me I would be *very* happy. # ps301d|bigps|qms|QMS-2210 in E301D:lp=/dev/ttyb:sd=/var/spool/ps301d:af=/var/adm/ps301d.acct:lf=/var/spool/ps301d/errs:br#9600:rw:fc#0000374:fs#0000003:xc#0:xs#0040040:mx#0:rg=printer:sf:sh:if=/local/lib/ps/psif:of=/local/lib/ps/psof:cf=/cis/reef/wp42/bin/wplpr:df=/local/lib/ps/psdf:gf=/local/lib/ps/psgf:nf=/local/lib/ps/psnf:rf=/local/lib/ps/psrf:tf=/local/lib/ps/pstf:vf=/local/lib/ps/psvf: # I know that perl can most likely solve this probelm nicely, so I am willing to hear of any responses, but for standardaztion I would like to use only standard unix filters. Sorry Larry. -- Brian J. Smith Work: 904-392-1183 CIS Sys Admin Staff 301 CSE Building bjs@cis.ufl.edu Univ of Florida, 32612
deschamp@minos.inria.fr (Philippe Deschamp) (12/01/90)
In article <25665@uflorida.cis.ufl.EDU>, bjs@reef.cis.ufl.edu (Brian J. Smith) writes: |> I have searched high and low for the answer on how to strip a NEWLINE |> charactor from a file. Well not really a NEWLINE char, but a ":\\\n" |> (colon,back-slash,newline). I have tried useing sed with: |> |> sed 's/:\\\n//' file |> |> and using the RS variable in awk, but to no avail. sed will remove |> the colon and the back-slash, but not the newline. The key is that "\n Matches a NEWLINE embedded in the pattern space." (from sed(1)). So you must embed a NL in the pattern space! With the "N" command, for example. The following does what you asked for, I should think: sed -e ': more /:\\$/{ N s/:\\\n *:*/:/ t more }' You can read this as while the current line ends with ":\", do append next line to current, with NL in between, get rid of "\", the NL and some TABs and superfluous ":"s end while Have fun! Sed is a wonderful tool, as long as you don't overuse it... Philippe Deschamp. Tlx: 697033F Fax: +33 (1) 39-63-53-30 Tel: +33 (1) 39-63-58-58 Email: Philippe.Deschamp@nuri.inria.fr || ...!inria!deschamp Smail: INRIA, Rocquencourt, BP 105, 78153 Le Chesnay Cedex, France
lugnut@sequent.UUCP (Don Bolton) (12/01/90)
In article <25665@uflorida.cis.ufl.EDU> bjs@reef.cis.ufl.edu (Brian J. Smith) writes: > >When TFM fails, when all the books I have fail, I run to netland. > >I have searched high and low for the answer on how to strip a NEWLINE >charactor from a file. Well not really a NEWLINE char, but a ":\\\n" >(colon,back-slash,newline). I have tried useing sed with: > > sed 's/:\\\n//' file > >and using the RS variable in awk, but to no avail. sed will remove >the colon and the back-slash, but not the newline. > >Here is the section of code that I am playing with. Not taking time to play with it but. a printf statement in awk will not input a newline unless you specify one. { printf("%s|%s|%s|%s|%s|%s ", $1, $2, $3, $4, $5, $6) } (assuming you want the pipe char as a seperator) > ># >ps301d|bigps|qms|QMS-2210 in E301D:\ > :lp=/dev/ttyb:sd=/var/spool/ps301d:\ > :af=/var/adm/ps301d.acct:lf=/var/spool/ps301d/errs:\ > :br#9600:rw:fc#0000374:fs#0000003:xc#0:xs#0040040:\ > :mx#0:rg=printer:sf:sh:\ > :if=/local/lib/ps/psif:of=/local/lib/ps/psof:\ > :cf=/cis/reef/wp42/bin/wplpr:df=/local/lib/ps/psdf:\ > :gf=/local/lib/ps/psgf:nf=/local/lib/ps/psnf:\ > :rf=/local/lib/ps/psrf:tf=/local/lib/ps/pstf:\ > :vf=/local/lib/ps/psvf: ># > >This is what I want the file to look like after the (colon,back-slash,newline) >has been striped. As you can see what I really want is to strip a >(colon,back-slash,newline,tab), but if someone could just get rid of that >darn newline for me I would be *very* happy. > ># >ps301d|bigps|qms|QMS-2210 in E301D:lp=/dev/ttyb:sd=/var/spool/ps301d:af=/var/adm/ps301d.acct:lf=/var/spool/ps301d/errs:br#9600:rw:fc#0000374:fs#0000003:xc#0:xs#0040040:mx#0:rg=printer:sf:sh:if=/local/lib/ps/psif:of=/local/lib/ps/psof:cf=/cis/reef/wp42/bin/wplpr:df=/local/lib/ps/psdf:gf=/local/lib/ps/psgf:nf=/local/lib/ps/psnf:rf=/local/lib/ps/psrf:tf=/local/lib/ps/pstf:vf=/local/lib/ps/psvf: ># > >I know that perl can most likely solve this probelm nicely, so I am willing to >hear of any responses, but for standardaztion I would like to use only standard >unix filters. Sorry Larry. >-- >Brian J. Smith Work: 904-392-1183 >CIS Sys Admin Staff 301 CSE Building >bjs@cis.ufl.edu Univ of Florida, 32612
smk@cbnews.att.com (Stephen M. Kennedy) (12/01/90)
In article <1781@seti.inria.fr>, deschamp@minos.inria.fr (Philippe Deschamp) writes: > [sed script to remove \<new-line>] > sed -e ': more > /:\\$/{ > N > s/:\\\n *:*/:/ > t more > }' Anybody got any ideas on how to make this script work on input of the form one:\ two:\ three:\ oops:\ <EOF> Currently, the N command aborts and the script produces no output on the last iteration; I'd like it to just act as if the last \ wasn't there. Steve Kennedy smk@cbosgd.att.com smk@cbnews.att.com
skwu@boulder.Colorado.EDU (WU SHI-KUEI) (12/04/90)
tr -d '\012' < file will strip newlines. Use 'sed' first if removing other stuff, e.g. sed 'whatever' file | tr -d '\012'