Shell $,/r getting added in echo on variable substitution.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell $,/r getting added in echo on variable substitution.
# 1  
Old 07-17-2011
Shell $,/r getting added in echo on variable substitution.

Hi All,

I'm trying to run a similar script to copy a files from one location to another.

Code:
#!/bin/bash
source="/home/pradeepk/a.txt"
destination="/home/pradeepk/dir1"
cp $source $destination

i'm getting following error.
Code:
cp: cannot stat `/home/pradeepk/a.txt\r': No such file or directory

when i debug this i found this output.

Code:
+ source=$'/home/pradeepk/a.txt\r'
+ destination=$'/home/pradeepk/dir1\r'
+ cp $'/home/pradeepk/a.txt\r' $'/home/pradeepk/dir1\r'
cp: cannot stat `/home/pradeepk/a.txt\r': No such file or directory

Can anyone help me on this..?

Thanks in advance.
Pradeep Kumar.
# 2  
Old 07-17-2011
Use a Unix/Linux editor or remove the Carriage Returns with:
Code:
tr -d '\r' < dosfile > unixfile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Validation to be added in the shell script

I need help with one of my shell script. The script is working fine but i need to add two condition - i need to get rid of all the below ftp messages and need to have only ftp completed or failed message. example when i run the script i get below lines - Connected to xxxx 220 (vsFTPd... (1 Reply)
Discussion started by: chandraprakash
1 Replies

2. Shell Programming and Scripting

Shell script worked correctly until I added variable :(

Hi everyone, I have been using a shell script for the last 6 months to copy a database from a POS system, then analyse the database and print the current sales total. This has worked flawlessly, the only issue was that I had hard coded the IP address of the POS and occasionally I would need to... (23 Replies)
Discussion started by: gjws
23 Replies

3. Shell Programming and Scripting

Command substitution in echo

a=1 b1=unix echo $b`$a` The above code is not working. Instead of printing the variable b1 using 'echo $b1', how to use variable 'a' to print 'b1' (1 Reply)
Discussion started by: thulasidharan2k
1 Replies

4. Shell Programming and Scripting

How to use variable with command substitution in variable

For example I have variable like below echo $OUTPUT /some/path/`uname -n` when I try to use the variable OUTPUT like below cd $OUTPUT or cd ${OUTPUT} I am getting bad substituion error message $ cd $OUTPUT ksh: cd: bad substitution $ cd ${OUTPUT} ksh: cd: bad substitution ... (1 Reply)
Discussion started by: rajukv
1 Replies

5. Shell Programming and Scripting

Need to echo a text where a (.) is added to the end of line during on-going copy or ftp

Hello All, I would like to create a script to echo a text where a (.) dot is added every 2 seconds to the end of this text (with a limit of 10 dots) as long as a file copy or ftp is ongoing and once the copy is finished it adds "done" to the end of this text line. please see the below example: ... (6 Replies)
Discussion started by: Dendany83
6 Replies

6. Shell Programming and Scripting

Using echo to print double quotes along with variable substitution

Hi, I am generating html code using cshell, but i am having one problem while printing double quotes, I need to write following code in file. where $var contains list of web address <a href="$var">$var</a> So i am using echo "<a href="$var">$var</a>" > file.html But with this " in... (4 Replies)
Discussion started by: sarbjit
4 Replies

7. Shell Programming and Scripting

Variable Substitution

Hi , I have a variable as follows, Temp=`cat ABC.txt | cut -c5-` This will yeild a part of the date. say , 200912. I would like to substitute this variable's value in a filename. eg: File200912F.zip when i say File$TempF.zip , it is not substituting. Any help ? Thanks in... (2 Replies)
Discussion started by: mohanpadamata
2 Replies

8. UNIX for Dummies Questions & Answers

Command substitution within an echo

I'm trying to get this to work and I'm not really sure how to do it. echo $x | awk '{print $NF}' MODIFIEDThe output I'm trying to get should look like: dir1 MODIFIED Where dir1 will be the result of: $x |awk '{print $NF}'I'm sure there's something I'm supposed to put around that part... (3 Replies)
Discussion started by: ewoods
3 Replies

9. Shell Programming and Scripting

Sed variable substitution when variable constructed of a directory path

Hello, i have another sed question.. I'm trying to do variable substition with sed and i'm running into a problem. my var1 is a string constructed like this: filename1 filerev1 filepath1 my var2 is another string constructed like this: filename2 filerev2 filepath2 when i do... (2 Replies)
Discussion started by: alrinno
2 Replies

10. UNIX for Dummies Questions & Answers

variable substitution

Hi everyone, I have a simple question to ask : In a script that I'm writting, I need to create variables on-the-fly. For instance, for every iterartion of the following loop a var_X variable should be generated : #!/bin/ksh a="1 2 3" for i in $a do var_${i}=$i echo "${var_$i}" done ... (1 Reply)
Discussion started by: ck-18
1 Replies
Login or Register to Ask a Question