How to print Following string?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to print Following string?
# 1  
Old 04-26-2011
Network How to print Following string?

Dear All,
I am new to shell script.I want to print following string:
"E:\OutputRef\ExtendedTestObjectModel\Test.txt"

For that i am using:
echo "$ADL_ODT_REF${ADL_ODT_SLASH}ExtendedTestObjectModel${ADL_ODT_SLASH}$ResultFile"

where - $ADL_ODT_REF is
E:\OutputRef
$
ADL_ODT_SLASH is \
ResultFile is Text.txt

But on printing it will show as :
"E:\OutputRef xtendedTestObjectModel\Test.txt"

\E get repalced by saome binary symbol
Please let me know is there any other way to print above line as it is?

Thanks in advance.

Sandeep

Also one thing i used ADL_ODT_SLASH twice before ExtendedTestObjectModel it works fine on windows but i think it will fail on unix.


Last edited by Sandeep Pattil; 04-26-2011 at 03:51 AM..
# 2  
Old 04-26-2011
Code:
~$ cat tmp.sh 
#! /bin/bash
ADL_ODT_REF="E:\OutputRef"
ADL_ODT_SLASH='\'
ResultFile="Text.txt"
echo "$ADL_ODT_REF${ADL_ODT_SLASH}ExtendedTestObjectModel${ADL_ODT_SLASH}$ResultFile"

~$ bash tmp.sh 
E:\OutputRef\ExtendedTestObjectModel\Text.txt

It seems there is something you are not telling us.
This User Gave Thanks to Skrynesaver For This Post:
# 3  
Old 04-26-2011
Try like this,
Code:
ADL_ODT_REF='E:\OutputRef'
ADL_ODT_SLASH='\'
ResultFile='Text.txt'
echo "$ADL_ODT_REF${ADL_ODT_SLASH}ExtendedTestObjectModel${ADL_ODT_SLASH}$ResultFile"

This User Gave Thanks to pravin27 For This Post:
# 4  
Old 04-26-2011
Thnks,,

But on printing it is showing as :
E:\OutputRef xtendedTestObjectModel\Text.txt

but \E is get replaced by some binary symbol
# 5  
Old 04-26-2011
Strange..try to escape the backslash:
Code:
ADL_ODT_REF='E:\OutputRef'
ADL_ODT_SLASH='\\'
ResultFile='Text.txt'
echo "$ADL_ODT_REF${ADL_ODT_SLASH}ExtendedTestObjectModel${ADL_ODT_SLASH}$ResultFile"

# 6  
Old 04-26-2011
Or perhaps
Code:
printf '%s%sExtendedTestObjectModel%s%s\n' "$ADL_ODT_REF" "$ADL_ODT_SLASH" "$ADL_ODT_SLASH" "$ResultFile"

Regards,
Alister
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find a string and print all lines upto another string

Ok I would like to do the following file test contains the following lines. between the lines ABC there may be any amount of lines up to the next ABC entry. I want to grep for the filename.txt entry and print the lines in between (and including that line) up to and including the last line... (3 Replies)
Discussion started by: revaroo
3 Replies

2. Shell Programming and Scripting

Print all lines after a string

My file has the following contents... User:SYS,O/SUser:oracle,Process:10813484,Machine:host123.xxx.xxx.xxxxxxx.com.au,Program:sqlplus@host123.xxx.xxx.xxxxxxx.com.au(TNSV1-V,LogonTime:24-JUL-2014 15:04 I would like to print all character appearing after the string LogonTime: My output... (5 Replies)
Discussion started by: Nagesh_1985
5 Replies

3. Shell Programming and Scripting

Print the word after the string

Hi I have a requirment here. I have to out the string after the particular word. for example i have the to extract the first word after the word disk. help me out. i have tried the folloing code but it is not giving the output which i need. awk -F"*disk " '{print $1}' grep -n -o '' file Input... (2 Replies)
Discussion started by: saaisiva
2 Replies

4. Shell Programming and Scripting

How to print everything after a string match

Hi all, I'm trying to do some work on the authorized_keys file to do a check if there's any information after the hash key.. At the end of the hash key's in the file, there can be an = or == Is there a way to check if anything exists after these equals and if so print it out or else print... (2 Replies)
Discussion started by: Jazmania
2 Replies

5. UNIX for Dummies Questions & Answers

Print part of string

I have a file called file.txt It contains strings: ALT=someone@acme.com TO=whoever@lalalulu.com How could find and print the actual address after the = sign for any given instance? I need the command to print one of them - for example someone@acme.com But have in mind that this... (3 Replies)
Discussion started by: svetoslav_sj
3 Replies

6. Shell Programming and Scripting

Help: Need to Print a string from a word

Hi Folks Can you please help me to grep a word from below test file Below is the file looks like ABCD Test:3 ZZZZYYYZZ ABCD TEST:38 XXXYYYZZZ I need below output echo $A=21455 echo $B=3 and for second line echo $A=324494 echo $B=38 I will use While read line for each line.. i... (7 Replies)
Discussion started by: Machha
7 Replies

7. UNIX for Dummies Questions & Answers

find string and and print another string

i have a file that looks like this ABC123 aaaaaaaaaaaaaaasssssssssssssssffhhh ABC234 EMPTY ABC652 jhfffffffffffffffffffffffffffffffffffkkkkkkkkkkkk i want to grep "EMPTY" and print ABC234 (3 Replies)
Discussion started by: engr.jay
3 Replies

8. Shell Programming and Scripting

Print the string between spaces

How to print the strings within a line between two spaces . <ns1:providerErrorCode>141</ns1:providerErrorCode> <ns1:providerErrorText>business_rule_exception-Server.404:Cannot proceed because the subscriber with phone number is either suspended or the account has an unpaid... (8 Replies)
Discussion started by: raghunsi
8 Replies

9. Shell Programming and Scripting

How to print a string using printf?

I want to print a string say "str1 str2 str3 str4" using printf. If I try printing it using printf it is printing as follows. output ------- str1 str2 str3 str4 btw I'm working in AIX. This is my first post in this forum :) regards, rakesh (4 Replies)
Discussion started by: enigmatrix
4 Replies

10. Shell Programming and Scripting

Grep a string and print a string from the line below it

I know how to grep, copy and paste a string from a line. Now, what i want to do is to find a string and print a string from the line below it. To demonstrate: Name 1: ABC Age: 3 Sex: Male Name 2: DEF Age: 4 Sex: Male Output: 3 Male I know how to get "3". My biggest problem is to... (4 Replies)
Discussion started by: kingpeejay
4 Replies
Login or Register to Ask a Question