C shell script last command not working - Ask Ubuntu


i have c shell (unfortunately c required) script called editfile.script consisting entirely of 6 different sed commands, applied 1 text file.

#!/bin/csh -f  1i gametime!!!!!!\n #append "gametime!!!!!! @ beginning s/pionts/points/g #sub typo s/shot/shoot/g #sub typo s/the\sthe/the/g #sub double the's "the" /^ *$/d #delete blank lines $a game\nover #append "game over" end of file 

now text file 400+ lines long , think posting here (and desired form) waste of space.

however, when run sed -f editfile.script gamemanual @ cmdline of above commands work except final command. no "game over" appended end of file. believe has preceding "delete blank lines /^ *$/d command- because when ran script removed, "game over" appended. don't see connection.

why final sed command in script not show? also, since first time using csh script (and c shell), other additions must make script work?

i don't think has c shell - , in fact, noted in comments, have sed script (a simple text file of sed commands) rather shell script, , #!/bin/csh -f shebang superfluous , treated (by sed) simple comment.

what seem observing sed appears not re-evaluate $ (last line) address, if 1 of previous commands happens delete last line of file, subsequent attempt append1 after address fails. can see simple test (using bash shell, it's worth) follows:

# delete line 3 append after $ $ printf 'line %d\n' {1..3} | sed -e '/3/d' -e '$a\new line' line 1 line 2 

whereas

# append after $ delete line 3 $ printf 'line %d\n' {1..3} | sed -e '$a\new line' -e '/3/d' line 1 line 2 new line 

i find surprising don't know if it's desired behavior or should considered bug.


note:

[1] techically, a command doesn't append, rather

queue[s] lines of text follow [ ... ] output @ end of current cycle, or when next input line read.


Comments

Popular posts from this blog

download - Firefox cannot save files (most of the time), how to solve? - Super User

windows - "-2146893807 NTE_NOT_FOUND" when repair certificate store - Super User