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:
c:/myFile.txt
c:\yourFile.txt
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:
>sed -n '/^.*\//p; /^.*\\/p' ./myFile.txt
c:/myFile.txt
c:\yourFile.txt
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
#!/bin/ksh
#set -xv
file=/myFile.txt
while read line
do
if [ `echo $line | sed -n '/^.*\//p; /^.*\\/'p` ] ; then
echo "path/filename: $line\n"
fi
done < $file
sed: command garbled: /^.*\//p; /^.*\/p
sed: command garbled: /^.*\//p; /^.*\/p
...
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