If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > unix command for add text

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-24-07, 23:31
erin_0502 erin_0502 is offline
Registered User
 
Join Date: Aug 2007
Posts: 11
Red face unix command for add text

anabody can help to solved my problem....

i want to add text to the first line and last line. Can anobody tell me what the unix command that i can use...
This is for example output that i want

abcde|||||||
fghijk
lmnop
qrstu|||||||

red line that part i want to add....
Reply With Quote
  #2 (permalink)  
Old 08-25-07, 02:56
Frunkie Frunkie is offline
Gives Bad Advice
 
Join Date: Mar 2007
Location: 010101010110100
Posts: 791
Quote:
Originally Posted by erin_0502
anabody can help to solved my problem....

i want to add text to the first line and last line. Can anobody tell me what the unix command that i can use...
This is for example output that i want

abcde|||||||
fghijk
lmnop
qrstu|||||||

red line that part i want to add....
Assuming that you want a pipe as indicated in your example:
Code:
sed 's/$/|/'
You must use the single quotes for this to work.
Reply With Quote
  #3 (permalink)  
Old 08-26-07, 04:16
Tyveleyn Tyveleyn is offline
Registered User
 
Join Date: Aug 2006
Location: The Netherlands
Posts: 248
To complete the sed command to meet the requirements:
Code:
sed -e '1s/$/|||||||/' -e '$s/$/|||||||/'
Regards
Reply With Quote
  #4 (permalink)  
Old 08-26-07, 20:54
erin_0502 erin_0502 is offline
Registered User
 
Join Date: Aug 2007
Posts: 11
Red face

thank for all attention.......
can u help me to teach me how can i try to using sed command because i new one in informix.....
Reply With Quote
  #5 (permalink)  
Old 08-26-07, 21:04
Frunkie Frunkie is offline
Gives Bad Advice
 
Join Date: Mar 2007
Location: 010101010110100
Posts: 791
Quote:
Originally Posted by erin_0502
thank for all attention.......
can u help me to teach me how can i try to using sed command because i new one in informix.....
What exactly are you trying to do? I don't see where informix ties into sed.
Reply With Quote
  #6 (permalink)  
Old 08-26-07, 22:46
erin_0502 erin_0502 is offline
Registered User
 
Join Date: Aug 2007
Posts: 11
opppsss sory....
thank for all of you, that command can solve my problem....but now i must to create simple coding to use this command....can anobody give me example coding using this command??????????
Reply With Quote
  #7 (permalink)  
Old 08-27-07, 00:39
erin_0502 erin_0502 is offline
Registered User
 
Join Date: Aug 2007
Posts: 11
hello.................
i can solved third promblem now....
can anobody help me, how to save that file....now when i run i get the correct output, but i view from file the file still come out without change anything. so i think this is because i don,t save yhat line into file....
help me plz....
Reply With Quote
  #8 (permalink)  
Old 08-27-07, 00:55
Frunkie Frunkie is offline
Gives Bad Advice
 
Join Date: Mar 2007
Location: 010101010110100
Posts: 791
Quote:
Originally Posted by erin_0502
hello.................
i can solved third promblem now....
can anobody help me, how to save that file....now when i run i get the correct output, but i view from file the file still come out without change anything. so i think this is because i don,t save yhat line into file....
help me plz....
You can redirect the output to a file like this:
Code:
sed 's/$/|/' > file
My UNIX does not require the "e" switch. Take your sed command and redirect it with the ">"
Reply With Quote
  #9 (permalink)  
Old 08-27-07, 01:10
erin_0502 erin_0502 is offline
Registered User
 
Join Date: Aug 2007
Posts: 11
i try to using that command but that is nothing...
but now when i run i get this syntax......

sed: command garbled: $s/$/|||||||//home3/users/bcs02/irni/txtfile/a.txt

MAIN
DEFINE
path CHAR(225),
sed CHAR(225)

LET path = "/home3/users/bcs02/irni/txtfile/a.txt"

LET sed = "\\sed -e '1s/$/|||||||/' -e '$s/$/|||||||/'", path
LET sed = sed CLIPPED

RUN sed

END MAIN
~
this is my simple coding.. can u help me.......i don't no what the problem...
Reply With Quote
  #10 (permalink)  
Old 08-27-07, 01:13
Frunkie Frunkie is offline
Gives Bad Advice
 
Join Date: Mar 2007
Location: 010101010110100
Posts: 791
Erin, what operating system are you using? UNIX or a linux distro?
Reply With Quote
  #11 (permalink)  
Old 08-27-07, 01:47
erin_0502 erin_0502 is offline
Registered User
 
Join Date: Aug 2007
Posts: 11
i using UNIX....
Reply With Quote
  #12 (permalink)  
Old 08-27-07, 01:59
Frunkie Frunkie is offline
Gives Bad Advice
 
Join Date: Mar 2007
Location: 010101010110100
Posts: 791
Erin,

I am not certain if you can run a UNIX command from within a static sql statement like you are trying to do. I can help you with UNIX but I don't know how to tell you to call it from your script. I'm sorry.
Reply With Quote
  #13 (permalink)  
Old 08-27-07, 06:07
Tyveleyn Tyveleyn is offline
Registered User
 
Join Date: Aug 2006
Location: The Netherlands
Posts: 248
Hi Erin,

First, the -e option with GNU sed means 'expression' and it's use with more than one expression in a Linux distribution is mandatory. Check in the man pages of your system what flag, if any, should be used. I believe Solaris sed uses the flag in the same way but I know AIX sed doesn't need a flag for this.
Second, you'd better check the UNIX shell script community for questions about sed because it's a pure OS tool, not an Informix one.
But since you've pasted it in 4GL I can give you the following example.
Code:
LET path = "/home3/users/bcs02/irni/txtfile/a.txt" 
LET sed = "\\/usr/bin/sed -e '1s/$/|||||||/' -e '$s/$/|||||||/' >", path 
LET sed = sed CLIPPED 
RUN sed
Comment:
The systemcommand RUN tries to execute needs to be of the same form as when executed from the commandline, so why do you write a backslash in front of sed?
Code:
LET sed = "sed -e ..."
will probably work OK, but better is to use the fullpathname of the command, which can be obtained on the commandline with
Code:
which sed
that shows the exact location of the sed program, usualy /bin or /usr/bin.

To redirect the stdout of sed (or any command in UNIX) to a file use '> filename' for a creating a new file (or overwriting one if it already exists) or '>> filename' for appending to an existing one (or creating a new one if it doesn't exist).
You don't have to undo the variable (with CLIPPED) from it's trailing spaces; the shell that's executing the sed command will ignore them automatically.

That should be it, try the command first on the commandline and if it works past it into the 4GL program.

Regards

Last edited by Tyveleyn; 08-27-07 at 06:13.
Reply With Quote
  #14 (permalink)  
Old 08-27-07, 21:06
erin_0502 erin_0502 is offline
Registered User
 
Join Date: Aug 2007
Posts: 11
Red face

i still have problem....
when i used ">" in my coding, nothing come out and output in filename empty...i try to using sed -n '/1s/,/$s/w out' input-file also cannot....
why in program ok when i run but not come out in filename... i think i pass the value to correct path...
Reply With Quote
  #15 (permalink)  
Old 08-27-07, 21:15
erin_0502 erin_0502 is offline
Registered User
 
Join Date: Aug 2007
Posts: 11
Red face

i still have problem....
when i used ">" in my coding, nothing come out and output in filename empty...i try to using sed -n '/1s/,/$s/w out' input-file also cannot....
why in program ok when i run but not come out in filename... i think i pass the value to correct path...
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On