manipulate postscript via sed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting manipulate postscript via sed
# 1  
Old 02-02-2009
manipulate postscript via sed

dear all,

on solaris10 for x86 i am trying to modify the creation date of a postscript file with sed in a csh script. sed is driving me crazy though...i think due to the spaces in the string i am trying to substitute??

part of the postscript file:
%!PS-Adobe-3.0
%---------------------------- Header --------------------------
%%Title: Default Title
%%Creator: Default Creator
%%CreationDate: Mon Feb 2 15:31:04 2009 - there are 2 spaces in front of the 2 originally!!

if i do:
Code:
set created = `more $PATH/file.ps | grep CreationDate | cut -d " " -f 2,3,4,5,6,7`
echo $created

it will give me:
Mon Feb 2 15:31:04 2009 though it should be "Mon Feb 2 15:31:04 2009" (there are 2 spaces in front of the day of the month if it is less than 10)
if i do:
Code:
echo $created | awk '{if ($3<10) $3=" "$3}{print}'

it will give me the same thing
and to make that complete if i want to declare the new date with
Code:
set new = "Tue Jan  2 14:14:23 2008"
echo $new

....guess what? same missing space?!

i was also looking for a tool within psutils but didn't find anything - does anyone have an idea how i could make the sed "s/${created}/${new}" file.ps work or any other way to manipulate the date of creation?
thank you very much from germany
ingo
# 2  
Old 02-02-2009
Use quotes
Code:
# echo $new
Tue Jan 2 14:14:23 2008
# echo "$new"
Tue Jan  2 14:14:23 2008

# 3  
Old 02-02-2009
Quote:
Originally Posted by lada niva
on solaris10 for x86 i am trying to modify the creation date of a postscript file with sed in a csh script.

Top Ten Reasons not to use the C shell
Csh problems
Csh Programming Considered Harmful
Quote:
sed is driving me crazy though...i think due to the spaces in the string i am trying to substitute??

part of the postscript file:
%!PS-Adobe-3.0
%---------------------------- Header --------------------------
%%Title: Default Title
%%Creator: Default Creator
%%CreationDate: Mon Feb 2 15:31:04 2009 - there are 2 spaces in front of the 2 originally!!

if i do:
Code:
set created = `more $PATH/file.ps | grep CreationDate | cut -d " " -f 2,3,4,5,6,7`


You don't need more:

Code:
grep CreationDate $PATH/file.ps | cut -d " " -f 2,3,4,5,6,7

Quote:
Code:
echo $created

it will give me:
Mon Feb 2 15:31:04 2009 though it should be "Mon Feb 2 15:31:04 2009" (there are 2 spaces in front of the day of the month if it is less than 10)
if i do:
Code:
echo $created | awk '{if ($3<10) $3=" "$3}{print}'


Quote the variable:

Code:
echo "$created"

Quote:
it will give me the same thing
and to make that complete if i want to declare the new date with
Code:
set new = "Tue Jan  2 14:14:23 2008"
echo $new

....guess what? same missing space?!
[/code]

No missing space, just missing quotes.
Quote:
i was also looking for a tool within psutils but didn't find anything - does anyone have an idea how i could make the sed "s/${created}/${new}" file.ps work or any other way to manipulate the date of creation?
thank you very much from germany
ingo
# 4  
Old 02-03-2009
what did the trick was:
Code:
set created = "`head -6 %PATH/file.ps | grep CreationDate  | cut -c  17-40`"

now sed will swallow it with the desired new date
Code:
more %PATH/file.ps | sed -e "s/${created}/${new_date}/" > %PATH/file_mod.ps

cheers
ingo
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Printing Postscript files through Infoprint Manager to a Postscript printer

Hello, I am runnning Infoprint Manager 4.3 on AIX 5.2 . There is no problem printing AFP files, but I have hit a snag trying to use "AIX DSS" or "Other Printer" actual destinations to send unconverted Postscript files to native Postscript printers. The files are big, and they print correctly,... (0 Replies)
Discussion started by: ahetzel
0 Replies

2. Shell Programming and Scripting

Manipulate "&" in sed

Is it possible to manipulate the ampersand in sed? I want to sum +1 to all numbers in a file. Example that doesn't work:sed "s/\{1,2\}/$(expr & + 1)/g" filenameAlso, how to return 02 instead of 2 from expr? (8 Replies)
Discussion started by: teresaejunior
8 Replies

3. Shell Programming and Scripting

Manipulate columns using sed

Hello, I would like to remove the first column of lines beginning by a character (in my case is an open square bracket) and finishing by a space (or any other delimiter). For example: string1 string2 string3 to string2 string3 I found this previous topic: ... (1 Reply)
Discussion started by: stoyanova
1 Replies

4. Shell Programming and Scripting

sed script to manipulate the /etc/passwd file

Hi. Can anybody help me with a script to extract usernames, shell and home_directory from the /etc/passwd file. I am stuck (2 Replies)
Discussion started by: Pauline mugisha
2 Replies

5. Shell Programming and Scripting

setpagedevice (postscript)

Basically, I'd like to apply a printer tray selection on postscript files by means of a (Bash) shell script. What works on a Xerox DocuColor 5000, is this (exemplified for one tray): sed "s/BeginPageSetup/&\n<<\/MediaColor (red)>> setpagedevice/" -i page.ps Every attempt to do so on a... (0 Replies)
Discussion started by: dr.house
0 Replies

6. Shell Programming and Scripting

Manipulate lines with sed/awk

Hey All, I need to reorganize a file's text. Here is the source: host John_Doe filename "config.cfg"; hardware ethernet 98:10:3d:13:8f:98; fixed-address 10.10.10.29; } host Jane_Doe filename "config.cfg"; hardware ethernet 98:13:11:fd:5a:57; fixed-address 10.10.5.24; } host... (2 Replies)
Discussion started by: TheBigAmbulance
2 Replies

7. Shell Programming and Scripting

RE or Sed to manipulate a document

I have a file with a list of about 2500 lines that I'd like to reformat using some regex in notepad++ or sed from my box (FreeBSD 6.3-RELEASE i386) to do the following: convert from: mycommand > mydocument0.htmlbcfn mycommand > mydocument1.htmlcdcsfn mycommand > mydocument2.htmldechfn... (6 Replies)
Discussion started by: phpfreak
6 Replies

8. Shell Programming and Scripting

Sed command to find, manipulate and replace a number

Hi, Im very new to the world of sed so I'm really not even sure if this is possible. What i need to do is read from a flat file and every time i see this line: VAL=123,456 I need to change 456 to 457 for every occurence of this line in the file. The numbers 123 and 456 are different for... (6 Replies)
Discussion started by: LT_2008
6 Replies

9. UNIX for Dummies Questions & Answers

using sed to manipulate text in files

Hi, I have a slight problem in trying to manipulate the text within a file using the "sed" command in that the text i need changed has "/" slashes in. I have a .sh script that scans the "/db/sybbackup/" directories for any .dmp file older than 2 days and then to >> the information to a file called... (3 Replies)
Discussion started by: Jefferson333
3 Replies

10. Shell Programming and Scripting

sed or other tool to manipulate data, including email addresses

I have a list of names and email addresses, like this. The <tab> markers are actually tabs. joe.blow <tab> joe.blow@wherever.com tom.t.hall <tab> tom.t.hall@wherever.com john.r.smith <tab> john.r.smith@wherever.com sally.jones <tab> sally.jones@state.or.us I want to parse the data so that... (3 Replies)
Discussion started by: manouche
3 Replies
Login or Register to Ask a Question