sed command not working inside ksh script but works fine outside
Hi,
I am a bit confused ,why would a sed command work fine outside of ksh script but not inside.
e.g
I want to replace all the characters which end with a value and have space at end of it.
so my command for it is :
This is working fine in and outside of the ksh script.
Another e.g
I want to remove last character from every line in the file.So the above command works fine outside of ksh script but not inside.
Also,
I am trying to execute below command to remove all Acaret junk characters.
This too works fine outside of ksh script but not inside.
Could somebody please help me explain why is it so and what can I do to resolve this.Also,what difference is it if I use double quotes in sed instead of single quotes.
I can't see a reason why those sed commands should not work within scripts. Is the SEPARATOR variable assigned to correctly? Execute the scripts with the -x option set, and post the log as well as input and output files (drop the -i for this).
Thanks for the suggestion I checked with the -x flag and found that the value is not resolved for $SEPARATOR.
Still I am facing issues with the caret A £ symbol from the string.I am trying to remove it from the file completely so using the below command:
But it does not make any changes to the file and the £ is still seen.
But this above command when submitted from outside the script works.
Any way to remove this from the file ?
Hi,
For the first command sed that not work in ksh script, try as:
But, maybe not work again, what is $SEPARATOR ?
How to launch your ksh script ?
For information, accented character may not be in sed. these depend your locale.
EDIT: try as:
1- how to find octal value of character:
In my example, my text in File is FOOàBAR.
Here, I see that character "à" is in octal \303\240 but really value is \0303\0240.
And to replace "à" by nothing:
Regards.
Last edited by disedorgue; 10-05-2013 at 05:09 PM..
Reason: First problem is already fix and correct my response for second problem
@disedorgue: That's not quite right. Â is a two (or more) byte unicode character; sed will find it and replace it (at least my GNU sed version 4.2.1 does).
@vital_parsley: As long as you don't post the info requested, I'll be incapable to help.
Thanks guys for all the help.I followed your responses and found that my first mistake was the $SEPARATOR variable was out of scope of the block so was not resolving correctly.
Secondly the caret A was not getting removed from the file is because ..when the job ran the wrapper script changed the LANG variable and so the caret A was not getting removed.I have explicitly exported it in the script and now its fine.
@RudiC:Yes and No, sed will found in locale use.
If I use charmap ISO-8859-1:
If I use charmap UTF-8:
And therefore sed might not found character in file because it is not the same character set.
Hello all,
I am facing a weird issue while executing a code below -
#!/bin/bash
cd /wload/baot/home/baotasa0/sandboxes_finance/ext_ukba_bde/pset
sh UKBA_publish.sh UKBA 28082015 3
if
then
echo "Param file conversion for all the areas are completed, please check in your home directory"... (2 Replies)
Hi everyone
I have a problem with my script
If I try directly this command
/usr/bin/nice -n 19 mysqldump -u root --password="******" wiki_schneider -c | nice -n 19 gzip -9 > /point_de_montage/$(date '+%Y%m%d')-wiki-db.sql.gz
It works
But if I simply add this command in a script and... (8 Replies)
Hi friends,
I am using below script to do some work. But even though script is working fine but while executing it i am getting command not found error. :(
Here is the script :-
#!/bin/sh
Names="name.txt"
###main#####
for LINE in `cat ${Names}`
do
... (3 Replies)
Guys,
I need you help please.
The script below is not working correclty for checking via a awk/if statement . Can you tell me what i am doing wrong in the script code "if($1 == "$RETENTION_LEVEL") "
Syntax
RETENTION_LEVEL=`echo $LINE | cut -f2 -d" "`
echo " ==============... (4 Replies)
Hi,
I have a problem with a SED script that works fine on AIX but does not work properly on a Solaris system.
The ksh script executes the SED and puts the output in HTML in tables.
But the layout of the output in HTML is not shown correctly(no tables, no color). Can anyone tell if there is... (7 Replies)
Hello.
I would like to ask your help regarding the cp command. We are using a cp command to create a back-up copy of our file but to no avail. It's just not working. We already checked the file and directory permissions and all seems correct.
We have a script (ftp.script) which calls on... (1 Reply)
Hello All,
This is driving me nuts. Wrote a very simple script (it's in csh so sorry about that). Just something very simple though. Here is the catch. Works great from command line sometimes. Other times it runs no errors or anything but I never receive an email. Never runs from crontab... (6 Replies)
I have a very basic script that essentially sends a log file, via FTP, to a backup server. My cron entry to run this every night is:
55 23 * * * /usr/bin/archive_logs
The script runs perfectly when executed manually, and actually worked via cron for about three weeks. However, it mysteriously... (3 Replies)
I cannot seem to get this text file to format. Its as if the awk statement is being treated as a simple cat command.
I manned awk and it was very confusing. I viewed previous posts on this board and I got the same results as with the
the awk command statement shown here. Please help.
... (6 Replies)
Hello all,
This beats me. I have a script that executes some commands and redirects their output to some text files that I will parse. The commands are along the lines of:
dsmadmc -id=admin -pa=admin -outfile=/home/tools/qlog.txt q log f=d
If I just run the script it works. If I execute... (2 Replies)