display correctly variables with a \

 
Thread Tools Search this Thread
Special Forums UNIX and Linux Applications display correctly variables with a \
# 1  
Old 12-13-2011
display correctly variables with a \

Hi,

We are in AIX 5.3
In a shell program I use a variable coming from a file and containing a path : 'C:\temp\titi'

Z2='C:\temp\titi'
echo $Z2

When I want to print the variable with echo command , I have :
C: emp iti

How to have the correct variable ? Thanks
# 2  
Old 12-13-2011
Assigning the string as a literal seems to work okay on Redhat, but you could try escaping the backslashes (\\) on input - e.g.
Code:
Z2=$(sed 's/\\/\\\\/g' infile)

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

using sed command to display contents where line numbers are stored in variables

if i want to display the contents of a file between say line number 3 and 10 then i use the following command sed -n '3,10p' filename if this 3 was contained in x and 10 was contained in y then how wud this command modified? sed -n '$x,$yp' filename does not work..please advise (2 Replies)
Discussion started by: arindamlive
2 Replies

2. Shell Programming and Scripting

Escaping ** correctly

Hello This should be easy, but bash is giving me headaches. At the command line the following command works: duplicity --include /home --exclude '**' / file:///foo Doing that from a script is not straightforward. Note that it is basically a requirement that I place the... (3 Replies)
Discussion started by: brsett
3 Replies

3. Shell Programming and Scripting

Display variables in CAT area

Hi All, I've got a script to output YAML data, and I want to display data that's held inside variables inside one large CAT area. What's the easiest way to do this? cat << "END" --- classes: - general_image - $intro #Variable 1 - $mid #Variable 2 ... (2 Replies)
Discussion started by: glarizza
2 Replies

4. Shell Programming and Scripting

Unable to display correctly the contents of a file without a line feed

I am using AIX and ksh. I need to display the contents of a file that has a pid (process id). Because the file is open, it doesn't have the line feed or new line, so for some reason if I do this: `cat $pid` , where $pid is the name of the fully qualified file, it displays test3.sh: 426110:... (1 Reply)
Discussion started by: Gato
1 Replies

5. Shell Programming and Scripting

Is grep being used correctly?

My goal is to find files contain the "signal 11" string in a specific directory. I need the file details followed by the string. I wrote a script to test out and play with Shell command since it's my first time to write a Shell script. Let me cut the story short... this command line: if ... (2 Replies)
Discussion started by: sai0899
2 Replies

6. Shell Programming and Scripting

if not working correctly

Anyone have an idea why this if statement does not work correctly? "test2.sh" 18 lines, 386 characters #!/usr/bin/sh WARNING=80 CRITICAL=95 check_it() { if ] || ];then echo "YES ] || ]" else echo "NO ] || ]" fi } check_it 80.1 check_it 81.1 (3 Replies)
Discussion started by: 2dumb
3 Replies

7. HP-UX

HP-UX will not boot correctly

i've same failure too, but this command boot pri isl not work/not found Thanks! (1 Reply)
Discussion started by: pantas manik
1 Replies

8. UNIX for Dummies Questions & Answers

HP-UX will not boot correctly

I am an intern at a company with an HP visualize C160 running HP-UX B.10.20. It has stopped booting to the gui and, after some coaxing, will end up at a text-based menu screen but virtually nothing can be run from there. At first the computer ran through it's boot process then stopped at this... (5 Replies)
Discussion started by: intern
5 Replies

9. UNIX for Advanced & Expert Users

multiple DISPLAY variables

Hi there, What I am trying to do is export the same screen to 2 different machines at once. I know you can use: DISPLAY=IP:0.0 export DISPLAY to send a screen to one machine but is there a way to send the screen to two machines at once by a similiar (or completely different, for that... (3 Replies)
Discussion started by: QUartz Ite
3 Replies
Login or Register to Ask a Question