Date: Thu, 17 Jul 1997 16:15:48 +0200 (MET DST) From: Zahemszky Gabor <zgabor@CoDe.hu> To: freebsd-questions@freebsd.org (FreeBSD questions) Cc: andrsn@andrsn.stanford.edu, vas@vas.tomsk.su Subject: Re: sed question Message-ID: <199707171415.QAA00447@CoDe.hu> In-Reply-To: <Pine.BSF.3.96.970716162230.2655A-100000@andrsn.stanford.edu> from Annelise Anderson at "Jul 16, 97 04:25:19 pm"
next in thread | previous in thread | raw e-mail | index | archive | help
> So can awk; this awk script seems to replace newlines with spaces > (and that's all it does): > > BEGIN { > FS = "\n" > RS = "" > } > { > for ( i = 1; i <= NF ; ++i) > printf("%s", $i " ") > } Well, if i'd like to write it with awk instead of sed, the next would be a bit more compact: BEGIN { ORS=" " } /^/ or instead of the last actionless pattern, a more readable (a patternless action): {print} /* awk -v ORS=" " '{print}' */ By the way: if I know well, the problem with sed is that we CAN substitute a newline, but CANNOT print anything without it. Gabor -- #!/bin/ksh Z='21N16I25C25E30, 40M30E33E25T15U!' ;IFS=' ABCDEFGHIJKLMNOPQRSTUVWXYZ ';set $Z;for i { [[ $i = ? ]]&&print $i&&break;[[ $i = ??? ]]&&j=$i&&i=${i%?};typeset -i40 i=8#$i;print -n ${i#???};[[ "$j" = ??? ]]&&print -n "${j#??} "&&j=;typeset +i i;};IFS=' 0123456789 ';set $Z;X=;for i { [[ $i = , ]]&&i=2;[[ $i = ?? ]]||typeset -l i;X="$X $i";typeset +l i;};print "$X"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199707171415.QAA00447>