The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
sed search and replace recursively 2bone Shell Programming and Scripting 1 09-02-2009 07:05 PM
Recursively search for most recent modification lokisapocalypse Shell Programming and Scripting 2 04-17-2009 02:20 PM
find and replace a search string recursively in files mohanpadamata Shell Programming and Scripting 7 01-16-2009 02:22 PM
FTP command to search recursively in windows folder lakshmis10 Shell Programming and Scripting 6 10-18-2007 05:09 AM
Looking for a good way to search & destroy lines darthur UNIX for Dummies Questions & Answers 5 07-30-2002 12:14 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-30-2009
siegfried siegfried is offline
Registered User
  
 

Join Date: Oct 2005
Posts: 91
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 (permalink)  
Old 09-30-2009
Scrutinizer Scrutinizer is online now
Registered User
  
 

Join Date: Nov 2008
Posts: 618
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 03:32 PM..
  #3 (permalink)  
Old 09-30-2009
scottn scottn is offline Forum Advisor  
VIP Member
  
 

Join Date: Jun 2009
Location: Zürich, CH
Posts: 1,046
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 (permalink)  
Old 09-30-2009
Scrutinizer Scrutinizer is online now
Registered User
  
 

Join Date: Nov 2008
Posts: 618
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 (permalink)  
Old 09-30-2009
scottn scottn is offline Forum Advisor  
VIP Member
  
 

Join Date: Jun 2009
Location: Zürich, CH
Posts: 1,046
Hm. I have GNU 2.5.1 and it works just fine. (Redhat 4.1).

That's progress!
  #6 (permalink)  
Old 09-30-2009
Scrutinizer Scrutinizer is online now
Registered User
  
 

Join Date: Nov 2008
Posts: 618
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 05:20 PM..
  #7 (permalink)  
Old 09-30-2009
scottn scottn is offline Forum Advisor  
VIP Member
  
 

Join Date: Jun 2009
Location: Zürich, CH
Posts: 1,046
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.
Reply

Bookmarks

Tags
grep, tabs

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:28 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0