You are not logged in.

#1 27 Jan 2012 23:26

tshippee
Member
Registered: 27 Jan 2012
Posts: 2

Bash Shell Environment Issue \033

Hi,

When running bash command line I have an issue with variables being wrapped with escape characters "\033]" the variable display on the screen ok, but when they are piped to another command and used as input the problem arises.

For instance:

#### Directory with some files

tshippee@linux1:/tmp/tmp> ls -l
total 0
-rw-r--r--  1 tshippee users 0 2012-01-27 17:20 four
-rw-r--r--  1 tshippee users 0 2012-01-27 17:20 one
-rw-r--r--  1 tshippee users 0 2012-01-27 17:20 three
-rw-r--r--  1 tshippee users 0 2012-01-27 17:20 two

##### Simple script to get the list of files

tshippee@linux1:/tmp/tmp> for i in `ls -l | awk '{print $8}'`
> do
> echo $i >> test.file.txt
> done

#### cat the file or echo to the monitor and the data looks ok.

tshippee@linux1:/tmp/tmp> cat test.file.txt
four
one
three
two

### If I vi the file this is what is displayed.

^[[0mfour^[[0m
^[[0mone^[[0m
^[[0mthree^[[0m
^[[0mtwo^[[0m

### Here is my environment:

tshippee@linux1:/tmp/tmp> set -o
allexport          off
braceexpand        on
emacs              off
errexit            off
errtrace           off
functrace          off
hashall            on
histexpand         on
history            on
ignoreeof          off
interactive-comments    on
keyword            off
monitor            on
noclobber          off
noexec             off
noglob             off
nolog              off
notify             off
nounset            off
onecmd             off
physical           off
pipefail           off
posix              off
privileged         off
verbose            off
vi                 on
xtrace             off


#########
Not sure why this is happening, but have spent a good deal of time trying to figure it out.

Any suggestions appreciated.

Thanks.

Offline

#2 05 Feb 2012 23:46

tshippee
Member
Registered: 27 Jan 2012
Posts: 2

Re: Bash Shell Environment Issue \033

Answer: There is a bug in this verion of ls in Suse Linux:   (coreutils) 5.2.1 .
Workaround: Use "find"command instead. Has no issues. smile

Offline

Board footer

Powered by