The UNIX and Linux Forums  

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
how to find a file named vijay in a directory using find command amirthraj_12 UNIX for Dummies Questions & Answers 6 10-25-2008 01:37 PM
Can I know find syntax to find given date files bache_gowda Shell Programming and Scripting 3 03-26-2008 06:37 AM
Little bit weired : Find files in UNIX w/o using find or where command jatin.jain Shell Programming and Scripting 10 09-19-2007 07:47 AM
Find files older than 20 days & not use find halo98 Shell Programming and Scripting 2 05-18-2006 03:19 PM
command find returned bash: /usr/bin/find: Argument list too long yacsil Shell Programming and Scripting 1 12-15-2003 06:38 PM

Closed Thread
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-2006
bebop1111116 bebop1111116 is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 30
using find

I am at a point in my script where i need to use the find command. However i am not to familar with using it yet. Hopefully this will take care of that aparently with the correct option find can be used to list “plain” files, as distinct from directories. Something about it looking into files and taking a guess at what type of file it is. Well, i want it to display for me all the files with their sizes and for it to tell me which ones are text files.

Can anyone help me figure out how to use the find command?

thanks
  #2 (permalink)  
Old 09-30-2006
srikanthus2002's Avatar
srikanthus2002 srikanthus2002 is offline
Registered User
  
 

Join Date: Sep 2006
Location: Can u guess...!
Posts: 160
can you provide full details...atleast give an example
it would be better to give solution
  #3 (permalink)  
Old 09-30-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,763
try
Code:
cd my/directory
find . -type f -exec file {} \; | grep 'ASCII' | awk '{print $1}' | ls -l
  #4 (permalink)  
Old 09-30-2006
srikanthus2002's Avatar
srikanthus2002 srikanthus2002 is offline
Registered User
  
 

Join Date: Sep 2006
Location: Can u guess...!
Posts: 160
this command gives files
[sri]$ find . -type f -exec file {} \; | grep 'ASCII' | awk '{print $1}'
./y:
./file_name:


but this gives four files
[sri]$ find . -type f -exec file {} \; | grep 'ASCII' | awk '{print $1}' | ls -l
total 16
-rw-rw-r-- 1 upl upl 6 Sep 28 13:26 file_name
-rwxrwxrwx 1 upl upl 900 Sep 29 15:40 tt
-rwxrwxrwx 1 upl upl 79 Sep 29 16:32 x
-rwxr-xr-x 1 upl upl 74 Sep 30 15:31 y

pls check
  #5 (permalink)  
Old 09-30-2006
srikanthus2002's Avatar
srikanthus2002 srikanthus2002 is offline
Registered User
  
 

Join Date: Sep 2006
Location: Can u guess...!
Posts: 160
I made some changes in previous post

find . -type f -exec file {} \; | grep 'ASCII' | awk '{print $1}' | sed 's/\.\///' | sed 's/://' > out_file

for file in `cat out_file`
do
ls -l $file
done

it is working
  #6 (permalink)  
Old 09-30-2006
mph mph is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 58
You could do this if you don't want to create a file:
Code:
fname=`find . -type f -exec file {} \; | grep 'ASCII' | awk -F\: '{print $1}'`
echo "$fname" | while read line
do
 ls -l "$line"
done
Use the -F\: with awk, and double quotes on vars to catch file names with spaces etc... Not recommended if you have a LARGE number of files to sort through, but work well for most apps.
Closed Thread

Bookmarks

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 12:39 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