sed commands success / fail from commandline vs ksh script
solaris 5.10 Generic_138888-03 sun4v sparc SUNW,Sun-Fire-T200
I need a sed command that tests true when presented with lines that contain either forward and backslash.
input file:
It doesn't appear that sed (in my environment anyway) supports alternation.. (perhaps BRE vs extended?), so I tried multiple commands separated by a semi colon.
from the commandline:
all is well.. (or so it appears.. first shell script in 20 years and as spend most of my time in perl, I've never used sed.. )
cool.. I added it to the shell script..
shell script
I notice that the last slash from the search in the second sed command doesn't show up in the garbled message.. (just before the last print ('p'))
Is that a clue?
Is the escape incorrect?
Multiple command syntax wrong?
I've tried putting single quote around each command..
.. removing the silent flag (-n)..
I'll take any suggestions even related to my attempt at ksh.. as I said.. been a long time. thanks in advance..
Mark
read needs -r flag to be able to read backslash character properly
no need to use sed ksh has it's own glob matching either with case or if statements eg:
This User Gave Thanks to Chubler_XL For This Post:
Or split you two rules with -e. Also, note that ^.* is not required
ChublerXL.. I went with sed coupled with read in raw mode.. seems to work fine.. thanks
Rudi C much appreciated, but it appears that our version sed has not been cultivated to the point it handles extended regex..
. thanks again..
Mark
Hello all,
I have a question regarding the difference betwen cron and command line.
What I would like to do is to print a statement into a logfile if a script has been executed from cron or from command line.
It should be as:
#!/bin/bash
if <Check if this script has been... (3 Replies)
How do i check success status of a sed command execution i have the below script not sure if it is right approach to check status of execution using a function.
Also it looks like in the below sed command even if the search string doesn't exist in the file it is returning status as success as i... (6 Replies)
I am using SED to edit a file (called file)
the file contains the word "ERROR"
and I want to use SED to:
1. Search for text "ERROR"
If found,
2. Append new line with text "hoi"
I tried:
sed 's/ERROR/ a\hoi' file
sed 's/ERROR/ a\ hoi' file
I get all the time the error
sed:... (7 Replies)
I'm more familiar with bash/ksh that csh/tcsh. With that said, I recently ran across a problem with tcsh.
Our system admin recently installed purify on our solaris 8 system. In order to use purify you have to execute a Rational script in order to setup the paths and some environment variables... (3 Replies)
Hi Expert,
Below is a real production environment issue:
we are using shell script to FTP to a remote server and fetch around 150 files every day, for each file we need to keep a entry inside ORACLE DB table, before insert into table, each file has a associated logid, which need to be... (2 Replies)
Hi there,
I have a wapper script which passes the argument from command prompt to inner script.. It works fine as long as the argument containing single word. But when value contains multiple word with space, not working as expected. I tried my best, couldn't find the reason. Gurus, pls.... (2 Replies)
Hi,
I am having a problem running multiple commands in a autosys command line. For example I would like to run a perl script first and then add sleep command after that in the same autosys job like below
insert_job: xxxxxxxxx
command: `perlscript.pl ; sleep 180`
Perlscript.pl... (0 Replies)
I need a bit of help here on something simple.
I have a KSH script (must be KSH) that needs to change 2 positional variables in a CSV script.
The CSV script looks like this:
00001,010109,01/01/2009 00:01:01
00008,090509,09/05/2009 13:47:26
My AWK script will change $2 and $3 based... (4 Replies)
I know how to ping in Perl. That is easy. What I am wondering is if there is a way for Perl to determine whether the ping was successful or not. Or do I need to save the results out and parse the results seperately looking for the #of tries and successful revieves.
Thanks. (1 Reply)