Not sure if that title is decent, but here we go. I'm running this string of commands:
In case you're curious is takes the output of a PBS queue, removes all the leading spaces, removes all the linebreaks, removes the backslash escape character in front of any commas, then grabs the output between two strings, effectively extracting a variable from a large mess of output from PBS.
When I run that, it works just fine, all steps work perfectly. However, when I direct the output into a variable, the sed command to remove the backslash fails.
So, I simplified the problem:
echo "Hello\,World" | sed 's/\\,/,/' --> "Hello,World"
var=`echo "Hello\,World" | sed 's/\\,/,/'`; echo $var --> "Hello\,World"
Hi All,
Please help me with the below problem
if
then
$a=" "
fi
echo "ABC1abc" | sed 's/a/'$a'/'
The required output is : ABC abc
But I am getting the below error:
sed: -e expression #1, char 4: unterminated `s' command
Please help. (6 Replies)
Hi All,
How can i use a variable in a sed command ? I cant seem to get it to work as at present its just printing $i at the start of every line rather than the variable $1.
sed -e "s/^/\$i,|/"
Any help would be appreciated. (3 Replies)
Hi,
How can I redirect the output of a following command to a variable.
ftp myservername
ftp> user
(username) guptaji
331 Password required for guptaji.
Password:
ftp> size /home/salil/abc.dat
ftp> a='size /home/salil/abc.dat'
?Invalid command
I want to redirect value of size to... (1 Reply)
Hi All,
Can I use a variable (using this variable as a counter) in sed cmd?
something like below
sed -n '${COUNT}p'
But it's not working. Pls help.
Thanks.
Regards,
Amee
export COUNT=1
export COUNTER=`cat ${BINPATH}/$ALLOC_FILE.clean_1 | wc -l | tr -d " "`
while ... (3 Replies)
Hi,
I want to insert some text in the begning of each line. But issue is the text that i want to insert is stored into one variable. so my command look like
constr="`date | awk '{print $3"-"$2"-"$6}'`",MXGBTST1" "
sed 's/^/\$constr/g' alert_temp.csv
but sed command instead of taking... (3 Replies)
I have file File1.txt in which i have to replace a text using sed command
File1.txt contents
EURAMOUNTTOBEREPLACED
I have a AIX shell script for replacing the text AMOUNTTOBEREPLACED
Contents of the shell script
sum=27
sed 's/AMOUNTTOBEREPLACED/"$sum"/g' File1.txt >> temp
mv temp... (5 Replies)
I know this script is crummy, but I was just messing around.. how do I get sed's insert command to allow variable expansion to show the filename?
#!/bin/bash
filename=`echo $0`
/usr/bin/sed '/#include/ {
i\
the filename is `$filename`
}' $1
exit 0 (8 Replies)
I want to instert Category:XXXXX into the 2. line
something like this should work, but I have somewhere the wrong sytanx. something with the linebreak goes wrong:
sed "2i\\${n}Category:$cat\n"
Sample:
Titel Blahh Blahh abllk sdhsd sjdhf
Blahh Blah Blahh
Blahh
Should look like... (2 Replies)
The following creates a needed awk command from some preexisting variables and stores it in the variable i. I then redirect it to a new file change the permission on the file and run it as a script.
How can I do a simple redirect on this variable to the command line, instead of creating a new... (8 Replies)
Hi,
I am looking for a way to redirect the result from a command into a variable.
This is the scenario.
Using the find command I will be getting multiple records/lines back.
Here is the command I am using:
find /”path”/ -name nohup.out -print
This now is giving me the paths and file... (1 Reply)