Sponsored Content
Full Discussion: eval removes backslash
Top Forums UNIX for Dummies Questions & Answers eval removes backslash Post 302431161 by ygemici on Monday 21st of June 2010 05:21:46 AM
Old 06-21-2010
Quote:
Originally Posted by daudiam
I'm very sorry, I didn't mention the fact that I was using bash. So, the examples u gave don't give me the results that u mention. My question is :
Code:
eval echo \\h
eval echo \\\h

both give output as h, but
Code:
eval echo \\\\h

gives output as \h

Does eval here just remove backslashes (I know the use of eval in the case where substitutions occur)
* First of all let look the below

Code:
# echo \h\h\h\h
hhhh

\ --> does no effect to echo Smilie


* Anyway

Code:
 
# echo \++
++

first \ char is meaningless in here and echo after \ chars so \++

so echo already write on the newline
Code:
  \ is same --> echo \



Code:
 
# echo A
A
# echo \A
A

but the trick for use ""
use this to remove its special meanings

Code:
# echo "A"
A
# echo "\A"
\A

Anymore \ is calculating with "" too

Code:
 
# echo \\\\\++
\\++

\ and \\\\++
so echo \\\\++ --> is to be \\++
\\ \\ --> two backslah is mean (one backslah) + two backslah is mean (one backslah) --> one + one = two backslah ( \\ )

Code:
 
# echo "\\\\\++"
\\\++

"\" and \\\\++
so echo \\\\++ --> is to be \\\++
\\ \\ --> two backslah is mean (one backslah) + two backslah is mean (one backslah) --> one + one = two backslah ( \\ )
\\ plus "\" --> \\\ three backslah and ++ ---> \\\++





Now in examples

1-)
Code:
 
# echo \\++
\++

\ and \++
first \ char doesnt change in the output
so echo \++

2 -)
Code:
 
# echo \\\++
\++

\ and \\++
first \char .....
so echo \\++ --> is to be \++
because two \\ originally is one \
\\ --> \

3-)
Code:
 
[root@XXXx ~]# echo \\\\++ 
\\++

\ and \\\++
first \char .....
so echo \\\++ --> is to be \\++
\\ \ --> two backslah is mean (one backslah)+ one backslah --> one + one = two backslah ( \\ )

4-)
Code:
 
[root@XXXx ~]# echo \\\\\++
\\++

\ and \\\\++
so echo \\\\++ --> is to be \\++
\\ \\ --> two backslah is mean (one backslah) + two backslah is mean (one backslah) --> one + one = two backslah ( \\ )


* Eval ; so eval removes the first backslash..Smilie

Code:
 
[root@XXXx ~]# eval echo \\++ 
++

---> eval removes the backslash and echo processing..

Code:
 
[root@XXXx ~]# eval echo \\\++ 
++

---> eval removes the backslash and echo processing..

Code:
 
[root@XXXx ~]# eval echo \\\\++ 
\++

---> eval removes the backslash and echo processing..



Regards
ygemici
This User Gave Thanks to ygemici For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script removes itself

I have a script that reads from a file and deletes all files in tha path specified in the file.The problem,however, is the script also deletes itself from the home directory where I run it :-( #!/bin/ksh while read DAYS PURGE_PATH do cd $PURGE_PATH find . \( -type d ! -name . -prune \)... (5 Replies)
Discussion started by: kayarsenal
5 Replies

2. UNIX for Advanced & Expert Users

GAWK removes FS | on output

I have the simple gawk script below. When the script runs in the output of all the ITM lines the FS is replaced with a space, the Non ITM lines retain the | field separator. The ITM lines have many fields and I can't insert "|" between each field because some of the fields are blank. Is... (1 Reply)
Discussion started by: paulr211
1 Replies

3. Shell Programming and Scripting

Strange result of eval, how does eval really work with ssh?

Hi all, some small script with eval turned me to crazy. my OS is linux Linux s10-1310 2.6.16.53-0.8.PTF.434477.3.TDC.0-smp #1 SMP Fri Aug 31 06:07:27 PDT 2007 x86_64 x86_64 x86_64 GNU/Linux below script works well #!/bin/bash eval ssh remotehost date eval ssh remotehost ls below... (1 Reply)
Discussion started by: summer_cherry
1 Replies

4. Ubuntu

Aptitude removes all packages

Hi Team, Please find below error. I got this after i done something in aptitude. Actually i was trying to update all packages, but unfortunately I removed all packages. Now my server is down. When i boot it gives me me errors of missing .so files. Is there any way to repair my server... (2 Replies)
Discussion started by: paragnehete
2 Replies

5. UNIX for Advanced & Expert Users

perl/sed -i removes link

hello, is it a behavior of or that "-i" removes unix link . example : i create a file "src_file" and link it to "link_file" and then i start "perl -i" the link is removed. does another option exists to change content of a file without temporary files ? UNIX-Version: HP-UX and... (2 Replies)
Discussion started by: bora99
2 Replies

6. Shell Programming and Scripting

Error in eval eval command to print html tags

anyone has any info on why this is complaining??? vivek@vivek-c5e55ef2e ~/TAC $ zoneCounter=1 vivek@vivek-c5e55ef2e ~/TAC $ optUsage1=23% vivek@vivek-c5e55ef2e ~/TAC $ eval eval echo "<th>Zone $zoneCounter </th><th align=\"left\"> \$optUsage$zoneCounter </th>" -bash: syntax error... (1 Reply)
Discussion started by: vivek d r
1 Replies

7. Shell Programming and Scripting

Error in eval eval command to print html tags

anyone has any info on why this is complaining??? vivek@vivek-c5e55ef2e ~/TAC $ zoneCounter=1 vivek@vivek-c5e55ef2e ~/TAC $ optUsage1=23% vivek@vivek-c5e55ef2e ~/TAC $ eval eval echo "<th>Zone $zoneCounter </th><th align=\"left\"> \$optUsage$zoneCounter </th>" -bash: syntax error... (13 Replies)
Discussion started by: vivek d r
13 Replies

8. Shell Programming and Scripting

Sed: removes \ from text which causes issues

Hi all, Hoping someone hoping someone might be able to help. i've got the following sed command which i'm using in a bash script that i'm trying to use to insert a new line into an already existing file so i don't have to manually enter it when setting stuff up. the existing script test2/3 are... (3 Replies)
Discussion started by: springs2
3 Replies

9. UNIX for Dummies Questions & Answers

Why awk removes delimiters?

Code : echo "1,2,3,4"|awk -F "," 'NR==n{$3=a}1' n=1 a=45 Output : 1 2 45 4 Expected : 1,2,45,4 (4 Replies)
Discussion started by: Rajesh_us
4 Replies

10. Shell Programming and Scripting

awk removes delimiter unexpectedly

datafile: blah,blah,blah,blah,blah,blah,blah,blah,blah=0_nblah=0-- ,blah,blah,blah im using the following command to turn the "_n" and "-- " to just a space " " only in the $9th field. meaning, it has to make the changes only in the 9th column/field of the datafile. awk -F, '{... (1 Reply)
Discussion started by: SkySmart
1 Replies
All times are GMT -4. The time now is 05:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy