Visit Our UNIX and Linux User Community


How to recursively search and destroy tabs


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to recursively search and destroy tabs
# 1  
Old 09-30-2009
How to recursively search and destroy tabs

Inspite of my best efforts, eclipse 3.5 seems to continue to misbehave and insert tab characters in my source code.

How do I write a script execute from emacs to search all my files for tab characters and conveniently position me on the line of code that has the offending tab?

Here are my attempts that match lines with no tabs!

find . \( -name \*.xml -o -name \*.java \) | xargs grep -inr "\t"
find . \( -name \*.xml -o -name \*.java \) | xargs grep -inr "\\t"

What am I doing wrong? I'm using RHEL 3. Yeah -- I know it is ancient but it is not my choice of OS! (I would prefer something a little more modern!).

Siegfried
# 2  
Old 09-30-2009
I think the \t character is not defined in grep. Instead I think you could just type tab character in quotes. If your shell performs file name completion you can use CTRL-V [TAB].

Code:
find . \( -name \*.xml -o -name \*.java \) | xargs grep -n '   '

You do not need the -i and the -r options.

Last edited by Scrutinizer; 09-30-2009 at 05:32 PM..
# 3  
Old 09-30-2009
Hi.

\t works fine with grep (in single or double quotes). It just doesn't like the -i option.

But why would you search for a case-insensitive tab?
# 4  
Old 09-30-2009
Hi scottn,

I just tried and my grep (GNU grep 2.5.3) does not understand \t, it works fine with ctrl-v TAB however. With "\t" or '\t' it lists all the lines that contain the letter 't' .
# 5  
Old 09-30-2009
Hm. I have GNU 2.5.1 and it works just fine. (Redhat 4.1).

That's progress!
# 6  
Old 09-30-2009
FWIW I could not find a mentioning of escape sequences in the 2.5.3 grep man/info pages, whereas it is mentioned the awk and sed pages. Is it in your grep 2.5.1 man/info page?

Last edited by Scrutinizer; 09-30-2009 at 07:20 PM..
# 7  
Old 09-30-2009
Hi.

Like you, there's nothing in the grep man page, but awk says

Quote:
Within strings, certain escape sequences are recog-
nized, as in C. These are:
\\ A literal backslash.
\a The “alert” character; usually the ASCII BEL character.
\b backspace.
\f form-feed.
\n newline.
\r carriage return.
\t horizontal tab.
\v vertical tab.

Previous Thread | Next Thread
Test Your Knowledge in Computers #439
Difficulty: Easy
A graphics processing unit (GPU) is a specialized electronic circuit designed to rapidly manipulate and alter memory to accelerate the creation of images in a frame buffer intended for output to a display device.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search/Replace in multiple files recursively

Hi there, I am using AIX and trying to search and replace a string with another string in multiple files in different directories. I wanted to search replace in steps so I don't change all of the instance anywhere in the server at once, minimizing impact. STEP 1: -------- I first searched... (5 Replies)
Discussion started by: zaino22
5 Replies

2. Shell Programming and Scripting

Search and Destroy Script Direction Help

Being a beginner in scripting I am not sure the direction to take to accomplish the below task and would love suggestions. GOAL input file: domains.list Read input file, search in named.conf and find domain and delete entry for the purpose of cleanup activity. named.conf entry example zone... (8 Replies)
Discussion started by: djzah
8 Replies

3. Shell Programming and Scripting

Search and recursively enter new line after Nth character

Hi All, My file is a string of around 50K character. I'm trying to insert new line after every 320 character in my file. I know the command to insert newline, but problem is I'm not able to search 320th position. Please advice. (6 Replies)
Discussion started by: Amit786
6 Replies

4. UNIX for Advanced & Expert Users

Recursively search the string from a column in no. of files

i have a file named keyword.csv(contains around 8k records) which contains a no. of columns. The 5th column contains all the keywords. I want to recursively search these keywords in all .pl files(around 1k) and display the filename....Afterthat i will use the filename and some of the column from... (3 Replies)
Discussion started by: millan
3 Replies

5. Linux

Search files recursively

grep pattern filename To search for the pattern in all files in the current directory and the sub-directories recursively, what needs to be substituted in filename? (1 Reply)
Discussion started by: ravisingh
1 Replies

6. Shell Programming and Scripting

How to recursively search for a list of keywords in a given directory?

Hi all, how to recursively search for a list of keywords in a given directory?? for example: suppose i have kept all the keywords in a file called "procnamelist" (in separate line) and i have to search recursively in a directory called "target/dir" if i am not doing recursive search then... (4 Replies)
Discussion started by: neelmani
4 Replies

7. Shell Programming and Scripting

sed -s does not search recursively

I would like to export the 5th line from every file within a directory. I am using GNU sed because we have no Unix or Linux environment. I used the following statement: sed -s -n 5p c:\directory\*.* but I only get the 5th line from one of the files in the directory. I am desperate for a... (1 Reply)
Discussion started by: hollingv
1 Replies

8. Shell Programming and Scripting

sed search and replace recursively

Hi, I tried making a shell script which recursively search in a given directory for all files *.txt and then search and replace some text and after that save each file as $filename.dynamips.txt I would like to get this done with sed. I tried but couldn't get it to work. BTW this is not... (1 Reply)
Discussion started by: 2bone
1 Replies

9. Shell Programming and Scripting

Recursively search for most recent modification

Hello all, I'm trying to determine when the last time a file in a certain directory was modified. I don't care what file it is, I just want to know when it was last updated. So far I have ls -aRl --full-time --sort=time which is close. The problem is that it only sorts within folders, not... (2 Replies)
Discussion started by: lokisapocalypse
2 Replies

10. UNIX for Dummies Questions & Answers

Looking for a good way to search & destroy lines

What is a good way to find an entry in a .conf file and then remove all lines associated with that entry? I have a Samba server running on Linux that I would like to easily add/remove share entries in the smb.conf file without removing or deleting lines that are not associated with that section.... (5 Replies)
Discussion started by: darthur
5 Replies

Featured Tech Videos