| | |
Help with sed command please.
Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2007
Posts: 5
Reputation:
Solved Threads: 0
I have a text file that I want sed to add a few lines to right before an existing line.
What I want to add is:
currentpagedevice /InputAttributes get 0 get
dup null eq
{ pop }
{ dup length 1 add dict copy
dup /InputAttributes
1 dict dup /Priority [0 1 2 3] put
put setpagedevice
} ifelse
And I want it right before the line containing the following:
Page: 1 1
Here's what I have in a file called sedscript.sed, but it doesn't seem to do anything..:
s#Page: 1 1#\
\i\ncurrentpagedevice /InputAttributes get 0 get\ndup null eq\
\n{ pop }\n{ dup
length 1 add dict copy\
\ndup /InputAttributes\
\n1 dict dup /Priority [0 1 2 3] put\
\nput
setpagedevice\
\n} ifelsei#
Here's how I call it:
sed -f sedscript.sed def011.txt
Thanks for your help in advance.
What I want to add is:
currentpagedevice /InputAttributes get 0 get
dup null eq
{ pop }
{ dup length 1 add dict copy
dup /InputAttributes
1 dict dup /Priority [0 1 2 3] put
put setpagedevice
} ifelse
And I want it right before the line containing the following:
Page: 1 1
Here's what I have in a file called sedscript.sed, but it doesn't seem to do anything..:
s#Page: 1 1#\
\i\ncurrentpagedevice /InputAttributes get 0 get\ndup null eq\
\n{ pop }\n{ dup
length 1 add dict copy\
\ndup /InputAttributes\
\n1 dict dup /Priority [0 1 2 3] put\
\nput
setpagedevice\
\n} ifelsei#
Here's how I call it:
sed -f sedscript.sed def011.txt
Thanks for your help in advance.
Shell Scripting Syntax (Toggle Plain Text)
zsh 4.3.4% echo "Page 1 1"|sed '/Page 1 1/i\ currentpagedevice /InputAttributes get 0 get\ dup null eq\ { pop }\ { dup length 1 add dict copy\ dup /InputAttributes\ 1 dict dup /Priority [0 1 2 3] put\ put setpagedevice\ } ifelse' currentpagedevice /InputAttributes get 0 get dup null eq { pop } { dup length 1 add dict copy dup /InputAttributes 1 dict dup /Priority [0 1 2 3] put put setpagedevice } ifelse Page 1 1
•
•
Join Date: Oct 2007
Posts: 5
Reputation:
Solved Threads: 0
Cool thanks, so working with what you gave me. I tried to make this work with my file so I put it in the script as:
/*Page: 1 1*/i\
currentpagedevice /InputAttributes get 0 get\
dup null eq\
{ pop }\
{ dup length 1 add dict copy\
dup /InputAttributes\
1 dict dup /Priority [0 1 2 3] put\
put setpagedevice\
} ifelse
Then I ran the script with:
sed -f sedscript.sed def011.txt
But it still does not do anything...
/*Page: 1 1*/i\
currentpagedevice /InputAttributes get 0 get\
dup null eq\
{ pop }\
{ dup length 1 add dict copy\
dup /InputAttributes\
1 dict dup /Priority [0 1 2 3] put\
put setpagedevice\
} ifelse
Then I ran the script with:
sed -f sedscript.sed def011.txt
But it still does not do anything...
•
•
Join Date: Oct 2007
Posts: 5
Reputation:
Solved Threads: 0
lol, so I tried to copy and paste that exact string in instead of the reg exps and it seemed to start working. Thanks for all the help.
Now if only I could get my postscript file to print some pages from one print tray and then some pages from another, all within the same printjob. I have the code that seems to change the tray, but it only wants to do it once.
Now if only I could get my postscript file to print some pages from one print tray and then some pages from another, all within the same printjob. I have the code that seems to change the tray, but it only wants to do it once.
![]() |
Similar Threads
- Bash Mail script help (Shell Scripting)
- Replacing text (Shell Scripting)
- help with shell script padding files with spaces (Shell Scripting)
- [Bash] problem with script in sed command (Shell Scripting)
- Removing entries (Shell Scripting)
Other Threads in the Shell Scripting Forum
- Previous Thread: FireWall Back ups with Expect
- Next Thread: How to use Logical OR operator in C- Shell
Views: 1371 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for Shell Scripting





