LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-22-2005, 01:17 PM   #1
mijohnst
Member
 
Registered: Nov 2003
Location: Huntsville, AL
Distribution: RHEL, Solaris, OSX, SuSE
Posts: 419

Rep: Reputation: 31
find -name and moving to file


I'm trying to do something that I know worked before, but I must have forgotten a step or something.

I want to search some directories for specific file and output it to a file as a list. I thought it would be something like this:

find . -name *.tmp -print >> /tmp/list.txt

When I type this it prints a list of the files it finds on the screen, but nothing in the file I'm redirecting to. I've even tried:

find . -name *.tmp | printf "%s/n" >>/tmp/list.txt

I've had no luck. What am I doing wrong? Sorry, I know this is a basic tool...

Last edited by mijohnst; 08-22-2005 at 02:05 PM.
 
Old 08-22-2005, 01:43 PM   #2
zedmelon
Member
 
Registered: Jun 2004
Location: colorado, USA
Distribution: slack, oBSD
Posts: 119

Rep: Reputation: 24
-name ?

find ./ -name temp* >> /tmp/listit

just worked for me. Your example doesn't include the "-name" option, but i'm guessing it's a typo because your subject does.

If that doesn't work, try escaping the star since it's at the front of the search string.
 
Old 08-22-2005, 02:05 PM   #3
mijohnst
Member
 
Registered: Nov 2003
Location: Huntsville, AL
Distribution: RHEL, Solaris, OSX, SuSE
Posts: 419

Original Poster
Rep: Reputation: 31
Opps... yeah, I have been using -name and it still didn't work.

The strange thing about it is that when I leave off the print command, it just prints each file down the screen... I just cannot get it to copy into a file.
 
Old 08-22-2005, 02:42 PM   #4
mijohnst
Member
 
Registered: Nov 2003
Location: Huntsville, AL
Distribution: RHEL, Solaris, OSX, SuSE
Posts: 419

Original Poster
Rep: Reputation: 31
hey zedmelon... your suggestion worked. It will list the files if I do a:

find ./ -name temp* >> /tmp/list.txt

Makes me wonder how you'd do a find on files with a certain extension though.

Last edited by mijohnst; 08-22-2005 at 02:43 PM.
 
Old 08-26-2005, 02:47 PM   #5
txtedmacs
LQ Newbie
 
Registered: Aug 2005
Location: N.E. U.S.A.
Distribution: Ubuntu 05.10, 6.06 also have used: FC 3, 4 & 5
Posts: 15

Rep: Reputation: 0
Re: find -name and moving to file

Quote:
Originally posted by mijohnst
I want to search some directories for specific file and output it to a file as a list. I thought it would be something like this:

find . -name *.tmp -print >> /tmp/list.txt

When I type this it prints a list of the files it finds on the screen, but nothing in the file I'm redirecting to. I've even tried:

find . -name *.tmp | printf "%s/n" >>/tmp/list.txt

I've had no luck. What am I doing wrong? Sorry, I know this is a basic tool...
If you are just trying to get the list of files into another file, why are you wasting your time with the find command?

Use list:

ls -l *.tmp >> /tmp/list.txt

I also do something that may not be required with the find command. I use single quotes around the search string: '*.tmp', nonetheless if you just need the list use the list command. It's both simple and quick.

Hope I have not misread your intent.
 
Old 08-26-2005, 04:59 PM   #6
mijohnst
Member
 
Registered: Nov 2003
Location: Huntsville, AL
Distribution: RHEL, Solaris, OSX, SuSE
Posts: 419

Original Poster
Rep: Reputation: 31
Thanks txtedmacs! That works too... lol

If it sounds to easy, it's because it is.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help moving a file rajvirnijjar Linux - General 3 02-15-2005 09:21 AM
Moving a File... scott.holmes Linux - Software 7 08-06-2004 07:35 AM
can you help with moving file please ? SlackwareMan Linux - Newbie 2 07-29-2004 08:25 PM
moving a file dominant Linux - Newbie 4 03-31-2004 06:39 AM
Moving around my file system... slackMeUp Slackware 9 01-31-2004 06:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration