Try one of these commands:
or
The shell interpretes one of the backslash as an escape character if you use double quotes.
Try to echo the sed command to see what happens:
---------- Post updated at 09:28 PM ---------- Previous update was at 06:59 PM ----------
Just one question
those 2 command give the same output (I added -e to echo for interpreting special characters)
why in the first is not new line escaped ? If I want this I have to type like
Only thing which gives me sence is if first \ escapes second, so second \ is written and it escapes \n
But also this gives me the same result as previous and this gives me no sence
I assumed first escapes second (so far second \ is written because is escaped by first \), written \ (the second) escapes third \ (so third is also written) which escapes \n.
so my expected result is: s/$/\\\n/ and NOT s/$/\n/
Can someone explain that ?
I am asking because I have traouble write something like this into the script
if i type it directly to bash it runs with no problems
Hi $res is number of line e.g 4
and $name is username e.g tux123
Now it finnaly works I have mistake somewhere in quotes in script, also could you please explain those escaping sequences ?
I am a little confusing with escaping (maybe it is for another post, cause it is bash and not sed)
why following code gives the same result ? I assuming that in 1st case first \ escapes \n so output should be first\nsecond
but it is
first
second
also folowing gives the same result
Also I was trying eval, but did not work, why ? It is the same string echoed and then exected.
Could you please explain that or point me to some literature ? Thanks
Hello All,
I have a strange issue. I've created a shell script which connects to RMAN (Oracle Recovery Manager) and executes full DB backup. I then executed this script with nohup and in the background:
$ nohup my_script.sh > logfile.log 2>&1 &The issue is that when I tried to take a look into... (6 Replies)
Hi All,
I am facing a strange problem while grepping for a process. Here is the small script that i have written.
It will look for any process running with the parameter passed to the script.
If no process is running it should print appropriate message.
$ cat t.ksh
#!/bin/ksh
set -x
... (9 Replies)
I am trying to create an archive using tar. I am specifying a list of directories using the -L option. For testing purposes I created a simple directory structure:
/backup/test
/backup/test/test1
/backup/test/test2
The file specified by the -L option, named files.txt, contains:... (8 Replies)
I am not sure what is wrong, but I have some strange behavior when printing things out.
I do create a file with only one word test, no space, no new line etc.
nano file<enter>
test<ctrl x>y<enter>
Server 1 gets (fail)
awk '{print "+"$0"*"}' file
*test
Server 2 gets (OK)
awk '{print... (9 Replies)
Hi
I have script to to take backup and send mail to a group once a day.
One strange behavior I have observed recently is that most of the time the mail we receive is fine . But someday it just sends out mail without any subject with undisclosed recipients. I dont know how to find the cause... (0 Replies)
I have the following program:
int main(int argc, char** argv){
unsigned long int mean=0;
for(int i=1;i<10;i++){
mean+=poisson(12);
cout<<mean<<endl;
}
cout<<"Sum of poisson: "<< mean;
return 0;
}
when I run it, I get the... (4 Replies)
Dear guys;
when deleting repeated lines using nawk as below ;
Why the below syntax works?
nawk ' !a++' infile > outfile
and when using the other below syntax the nawk doesn't work?
nawk ' { !a++ } ' infile > outfile
or
nawk '
{
!a++
} ' infile > outfile
BR (4 Replies)
I have searched far and wide for an explanation for some odd behavior for output redirection and haven't come up with anything.
A co-worker was working on old scripts which have run for years and embedded in their code were output redirects which worked for the script during execution and then... (5 Replies)
I have a file called products.kp which contains, for example,
12345678,1^M
87654321,2^M
13579123,3
when I run the command
cat products.kp| sed -f kp.sed
where kp.sed contains
s,^M,,
I get the output
12345678,1
87654321,2
13579123,3 (5 Replies)