Tag Info

New answers tagged

1

Not really suitable for huge files but ed can read a command output and insert it after the addressed line, e.g.: ed -s desired.txt <<IN 4r !grep "key" temp_file w q IN or, in one line: printf '%s\n' '4r !grep "key" temp_file' w q | ed -s desired.txt You can insert the output from different commands at different line numbers just keep in mind you ...


0

GNU sed allows to do not use perl for such simple task: sed -z 's/\n+//g' trail.txt


0

A couple of ideas, since it'll be a bit tricky with sed: perl -00 -pe 's/\n\+\s*/ /g' file awk ' { if (/^\+/) sub(/^\+[[:blank:]]*/, " ", $0) else if (NR > 1) print "" printf "%s", $0 } END {print ""} ' file


2

FWIW, GNU awk awk -vRS='\\n\\+?' '{ORS=RT == "\n+"? "":RT; print}' trail.txt data net06706 net06707 net221 net222 net223 m1 net10 rwl vdda vss nch l="l1pg+0.005u" w=w1pg+0.105u m0 vdda rwld net10 vss nch l="l1pg+0.005u" w=w1pg+0.105u


2

I don't think you can use a backspace approach - however you could do something like sed -e :a -e '$!N;s/\n+/ /;ta' -e 'P;D' trail.txt See Famous Sed One-Liners Explained, Part I: File Spacing, Numbering and Text Conversion and Substitution, 40. Append a line to the previous if it starts with an equal sign "=" (with the obvious substitution of + for =).


0

Use Perl instead of sed: perl -ne 'chomp; print "\n" unless s/^\+// or 1 == $.; print }{ print "\n"' chomp removes newline. $. is the input line number.


2

setenv is a csh-only command, but system() runs its arguments through the Bourne shell (/bin/sh), not csh. You'd want to command to be export VARIABLE=value for Bourne shell. However, even if you do that, it will be ineffective. system() starts a new shell and runs the command in that shell. As soon as the command terminates, that shell — and its ...


1

man tcsh: $_ Substitutes the command line of the last command executed. (+)


-1

$ sed '4 a\ > `grep "key" temp_file`' desired.txt Try this one. Option a is for after line no. 4. You can also give option i for before line no. 4 Hopefully this should work.



Top 50 recent answers are included