Escape Sequences appearing in scripts


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Escape Sequences appearing in scripts
# 1  
Old 05-08-2008
Question Escape Sequences appearing in scripts

I hope this question isn't too vague...

i recently switched from RedHat to Solaris 10, and found that the parts of a script that copy files between directories no longer work because escape sequences are appearing at the start and end of the filenames being read

#!/usr/bin/bash
cd ${fromDirectory}
for file in `ls -1 bkup*`
do
cp $file ${toDirectory}
done

but the cp command fails, because there are escape sequences being inserted at the start and end of the filenames, and the file is therefore not being found.

I thought it could be some sort of stty issue or terminal setting which I've not set. Any ideas?
# 2  
Old 05-08-2008
First you need to quote your variables, then I'd recommend to rename those files later. The following modified code was tested with filenames with escape chars in them:

Quote:
$ ls
\test1 \
\test2 \
\test3 \

Code:
#!/usr/bin/bash
cd ${fromDirectory}

for file in *bkup*
 do
    cp "$file" "${toDirectory}"
 done

 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to remove escape sequences from a text file?

Hello friends, Could anyone please advise on how to remove escape sequences from a text file? $ file input.txt input.txt: ASCII English text, with escape sequences I'm able to see those escape characters when opened in vi editor like shown below: ^ but not when I run more... (6 Replies)
Discussion started by: magnus29
6 Replies

2. UNIX for Advanced & Expert Users

Re-appearing Files

Gurus I am running an AIX 7.1 system and have come across a strange issue. I am trying to delete files from a folder using standard 'rm' syntax. After i delete the files , files re-appear again. File renaming or editing does not help. Files re-appear with 0 bytes again. They are always 0... (5 Replies)
Discussion started by: abhijeet
5 Replies

3. Shell Programming and Scripting

Escape Sequences

Hi Gurus, Escape sequences \n, \t, \b, \t, \033(1m are not working. I just practiced these escape sequences. It worked first. Later its not working. Also the command - echo inside the script editor shows as shaded by a color. Before that echo inside the script editor wont show like this.... (4 Replies)
Discussion started by: GaneshAnanth
4 Replies

4. Shell Programming and Scripting

Auto escape script to escape special chars in script args

This is a bit off the wall, but I often need to run scripts where there are argument values that contain special characters. For example, $ ./process.exe -t M -N -o temp.mol.s -i ../molfiles/N,N\',N\'\'-trimethylbis\(hexamethylene\)triamine.mol && sfile_space_to_tab.sh temp.mol.s temp.s It... (1 Reply)
Discussion started by: LMHmedchem
1 Replies

5. Shell Programming and Scripting

Mail utility not displaying escape sequences

Hello! I created a file that displays text underlined. However when I pass the file into the mail utility it doesnt display the underline. Here is the code: echo "\n\033 cat test_underline.txt mail -s "testing of underline" <email_address> < test_underline.txt Any ideas?... (8 Replies)
Discussion started by: DPERTS
8 Replies

6. Shell Programming and Scripting

sendmail not appearing to ps

I am having trouble finding the process, or subsystem, sendmail running on our client's server. They are runnning AIX version 5.3.9.0. When I run "ps -ef | grep sendmail" I only get my current ps process as a match. Running "ps -ef | more" and wading through the results also does not show sendmail... (2 Replies)
Discussion started by: moviedude
2 Replies

7. UNIX for Dummies Questions & Answers

How to input escape sequences in Linux tty?

More details: Unicode, Framebuffer. I tried to press Esc and then what should follow, letters or brackets, but seems not to work. Probably i do something wrong. If somebody is familiar with escape sequences in the console, how do you do that? Thanks in advance. (4 Replies)
Discussion started by: Action
4 Replies

8. Solaris

Mounted Slice not appearing

Hi friends.. Here is my problem.. I mounted a slice and make it permanent through entering the information in /etc/vfstab file ,,,but when i give df -kh ,,in the output the slice information is not appearing..but i can be able to open the mount point and access files as usual..I didn't give... (6 Replies)
Discussion started by: sdspawankumar
6 Replies

9. Solaris

Available escape sequences

:) Hi, Can any one help me to find available escape sequences in UNIX shell programming? ( Like \n, \c etc,. in C or C++) Iam generating one report using one of the script, in that it is very much essential. Regards, LOVE (6 Replies)
Discussion started by: Love
6 Replies
Login or Register to Ask a Question