473,378 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Find files in Linux

I m kind of stuck ...i need to find files with a specific criteria but i can not make it work ....

These are the ones :

1.How do you Find files under /root that contain the whole words (i.e., not part of another word) 'foo', 'bar', 'baz', 'cat', 'cut', 'cot.' using a single command ?

I tried :find /root -name 'foo.*' -name 'baz.*'-name 'cat.*'-name 'cut.*'-name 'cot.*'
but seems that is not right

2.Find files under /var that contain the character list 'xxx' or 'xxxx' or 'xxxxx'. Using \{\} and adding two lines of context before AND after each keyword found. ..

my answer: find /var -name 'xxx' ,'xxxx, 'xxxxx'

At this point i am lost ....

Any help will be very much appreciated
Feb 1 '07 #1
4 3163
Motoma
3,237 Expert 2GB
I m kind of stuck ...i need to find files with a specific criteria but i can not make it work ....

These are the ones :

1.How do you Find files under /root that contain the whole words (i.e., not part of another word) 'foo', 'bar', 'baz', 'cat', 'cut', 'cot.' using a single command ?

I tried :find /root -name 'foo.*' -name 'baz.*'-name 'cat.*'-name 'cut.*'-name 'cot.*'
but seems that is not right

2.Find files under /var that contain the character list 'xxx' or 'xxxx' or 'xxxxx'. Using \{\} and adding two lines of context before AND after each keyword found. ..

my answer: find /var -name 'xxx' ,'xxxx, 'xxxxx'

At this point i am lost ....

Any help will be very much appreciated
For number 1, do you mean that have filenames containing those words, or the files themselves containing those words?
The tools you want in the latter case are grep and sed, not find.
Actually, I think both questions are looking for answers involving sed.

A little more on sed.
Required reading for sed (i.e. Regular Expressions).
Feb 2 '07 #2
No , i s not grep because we are looking for file names no strings within a file .
I know FIND must be used but i dont remember the correct parameters ..
Feb 2 '07 #3
Motoma
3,237 Expert 2GB
No , i s not grep because we are looking for file names no strings within a file .
I know FIND must be used but i dont remember the correct parameters ..
In the future, you can use the command line utility man to find syntax for linux commands:

Expand|Select|Wrap|Line Numbers
  1. % man find
  2.  
Here is a web version of the man page.
Feb 2 '07 #4
find /root -name 'foo' -print is the command to find files
Feb 11 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: hokiegal99 | last post by:
The below code does what I need it to do, but I thought that using something like ext = os.path.splitext(fname) and then searching ext for '.mp3' would be a much more accurate approach to solving...
1
by: Thieum22 | last post by:
Hi, I try to go through a directory and it's subdirectories to reah the properties of each files. But I have a problem to set active the directory where the files are, in order to display their...
3
by: Dean Arpajian | last post by:
Looking to find info/ libs on creating (small) video files. Basically what I'm looking for is a tutorial for constructing a short video... (nothing nasty: output from a transmission line...
15
by: David T. Ashley | last post by:
I'll be using gcc under Red Hat Enterprise Linux. Where do I find information about the low-level calls to the operating system from compiled 'C'? For example, if I want to cause a process to...
17
by: krishnakant Mane | last post by:
hello all, I am stuck with a strange requirement. I need a library that can help me display a pdf file as a report and also want a way to print the same pdf file in a platform independent way....
2
by: enquiring mind | last post by:
-learning python with limited knowledge of linux. -get error msg 21 "file or directory does not exist" -running Suse linux 10. -haven't had a problem before - rebooted several times. -python...
1
by: Kesavan | last post by:
I install apache2 in /usr/local/apache2 and install php5 by ./configure --with-apxs2=/usr/local/apache2/bin/ apxs PHP is successfully installed in my system. But now my .php files inside...
7
by: Patricia Mindanao | last post by:
I have a directory tree on my hard disc which represents all the web pages and linked stuff on my mirrored web hoster server. All web pages and files are statically linked. So dynamically...
3
by: michalkuls | last post by:
Hi, I have a problem with my linux apache+php installation. I don't know much about linux and it appears a real nightmare for me every time I need to change anything. When I look at the file...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.