UNIX Special Characters


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting UNIX Special Characters
# 1  
Old 06-09-2013
UNIX Special Characters

Any time I do :
Code:
ls *.txt > mytext.txt

I get something like this in the output file:
Code:
^[[0;32mCGRI0007.txt^[[0m*
^[[0;32mCGRI0008.txt^[[0m*
^[[0;32mCGRI0009.txt^[[0m*
^[[0;32mCGRI000.txt^[[0m*
^[[0;32mCGRI00.txt^[[0m*
^[[0;32mCGRI002.txt^[[0m*
^[[0;32mCGRI003.txt^[[0m*
^[[0;32mCGRI004.txt^[[0m*
^[[0;32mCGRI005.txt^[[0m*
^[[0;32mCGRI006.txt^[[0m*
^[[0;32mCGRI007.txt^[[0m*
^[[0;32mCGRI008.txt^[[0m*
^[[0;32mCGRI009.txt^[[0m*
^[[0;32mCGRI0020.txt^[[0m*

Code:
Tue Jan 22 16:19:19 EST 2013 x86_64 x86_64 x86_64 GNU/Linux
t1Fam_BrOv :~>alias | grep ls
alias l.='ls -d .* --color=tty'
alias lR='ls -R'
alias la='ls -Al'
alias lc='ls -ltcr'
alias ldd='ls -ltr | tail -10'
alias lk='ls -lSr'
alias ll='ls -l --group-directories-first'
alias lm='ls -al |more'
alias lr='ls -lR'
alias ls='ls -hF --color'
alias lt='ls -ltr '
alias lu='ls -ltur'
alias lx='ls -lXB'

Two questions:
1) Why do I get this.. what is.. contributing to this behavior.
2) how to get rid of this?
Moderator's Comments:
Mod Comment Please use CODE tags (not ICODE tags) whenever posting more than one line of code, input, or output.

Last edited by genehunter; 06-10-2013 at 12:30 PM.. Reason: Use appropriate tags.
# 2  
Old 06-09-2013
Can switch off color and try:
Code:
ls --color=never

This User Gave Thanks to Yoda For This Post:
# 3  
Old 06-09-2013
Looks like your ls is emitting ansi terminal escape sequences even when not writing to a terminal. Your ls may be configured with --color or --color=always.

Regards,
Alister
# 4  
Old 06-10-2013
Yoda gave you directions on how to turn off color for a particular invocation of ls (assuming that you're using a Linux system).

To turn it off permanently for future invocations of ls, we need to know what OS you're using, whetter or not you have an alias in place for ls, whether the following variables are set in your shell's execution environment (LS_COLOR, CLICOLOR, CLICOLOR_FORCE, and LSCOLORS) and if they are set what values they have.

If the suggestions given so far don't help you correct the problem, please show us the output from the following three commands:
Code:
uname -a
alias | grep ls
set | grep COLOR

This User Gave Thanks to Don Cragun For This Post:
# 5  
Old 06-10-2013
Maybe you have a setting for the PS1 variable (color prompt) that give this output.
Id did mess with my PS1 and did get lot of strange output.
# 6  
Old 06-10-2013
Quote:
Originally Posted by Don Cragun
Yoda gave you directions on how to turn off color for a particular invocation of ls (assuming that you're using a Linux system).

To turn it off permanently for future invocations of ls, we need to know what OS you're using, whetter or not you have an alias in place for ls, whether the following variables are set in your shell's execution environment (LS_COLOR, CLICOLOR, CLICOLOR_FORCE, and LSCOLORS) and if they are set what values they have.

If the suggestions given so far don't help you correct the problem, please show us the output from the following three commands:
Code:
uname -a
alias | grep ls
set | grep COLOR

I added the aliases, and yes, I do have COLOR.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Need help to delete special characters exists only at the end of the each record in UNIX file?

Hi, I have a file in unix with 15 columns.It consists special characters(#,$,^M,@,*,% etc)at the end of the each record.I want to remove these special characters.I used the following: Sed -e 's/ /g;s/ */ /g' . But It is removing special characters exists everywhere in the file(begining,middle... (24 Replies)
Discussion started by: rakeshp
24 Replies

2. Shell Programming and Scripting

Special Characters BASH/UNIX term support

Trying to run this command: find /Volumes/Archive/ -type f -name "Icon" and get /Volumes/Archive//New Business and Marketing/2010 /Creative/Image Library/Stuff for Sean/Cafe Heineken/logo_Café Heineken_03.jpg: No such file or directory due to the accent on the filename. Is there a way around... (2 Replies)
Discussion started by: kostas123334
2 Replies

3. Shell Programming and Scripting

Windows to UNIX FTP Special characters!

I have a file that has the name in one of the lines as MARíA MENDOZA in Windows. When this gets FTPed over to UNIX it appears as MAR�A MENDOZA. Is there anyway to overcome this? Its causing a issue because the file is Postional and fields are getting pushed by 2 digits.. Any help would be... (4 Replies)
Discussion started by: venky338
4 Replies

4. Shell Programming and Scripting

Replace special characters with Escape characters?

i need to replace the any special characters with escape characters like below. test!=123-> test\!\=123 !@#$%^&*()-= to be replaced by \!\@\#\$\%\^\&\*\(\)\-\= (8 Replies)
Discussion started by: laknar
8 Replies

5. Shell Programming and Scripting

Single/Multiple Line with Special characters - Find & Replace in Unix Script

Hi, I am creating a script to do a find and replace single/multiple lines in a file with any number of lines. I have written a logic in a script that reads a reference file say "findrep" and populates two variables $FIND and $REPLACE print $FIND gives Hi How r $u Rahul() Note:... (0 Replies)
Discussion started by: r_sarnayak
0 Replies

6. Shell Programming and Scripting

Special characters

When I open a file in vi, I see the following characters: \302\240 Can someone explain what these characters mean. Is it ASCII format? I need to trim those characters from a file. I am doing the following: tr -d '\302\240' ---------- Post updated at 08:35 PM ---------- Previous... (1 Reply)
Discussion started by: sid1982
1 Replies

7. UNIX for Dummies Questions & Answers

Advice on extracting special characters from a DB2 table to a file in the UNIX ENV

need some advice on the following situation. I have a DB2 table which has a varchar Column. This varchar column can have special characters like ©, ®, ™ . When I extract from this table to a sequential file for this varchar column I am only able to get © and ® . To Get the ™... (1 Reply)
Discussion started by: cosec
1 Replies

8. UNIX for Dummies Questions & Answers

Unix file does not display special characters

We have a unix file that contains special characters (ie. Ñ, °, É, ¿ , £ , ø ). When I try to read this file I get a codepage error and the characters are replaced by the # symbol. How do I keep the special characters from being read? Thanks. Ryan (3 Replies)
Discussion started by: Ryan2786
3 Replies

9. UNIX for Advanced & Expert Users

Special characters getting replaced by &Pound in Unix Environment

Hi, Please find the Question Summary below- In our email template document(.txt) bullets and Apostrophe are getting replaced by the string "&pound" in our Live environment.We are using sun solaris 8 in live. Can anybody let me know why this happens and how to prevent this . Thanks... (0 Replies)
Discussion started by: kaushik05
0 Replies

10. UNIX for Dummies Questions & Answers

special characters

I have one file which is named ^? ( the DEL character ) I'd like to know how to rename or copy the file by using its i-node number TYIA (2 Replies)
Discussion started by: nawnaw
2 Replies
Login or Register to Ask a Question