LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 07-24-2013, 11:59 AM   #1
wdtunstall
LQ Newbie
 
Registered: Oct 2010
Location: Central VIrginia, USA
Distribution: Redhat 6.3
Posts: 1

Rep: Reputation: 0
Angry find: paths must precede expression: ls HELP!


I am trying to create text document which lists every file on the server. It is supposed to look in every sub-directory under <dir1> and <dir2> and do an 'ls -lh' and then send the output to a .txt file. However I am receiving the dreaded "find: paths must precede expression: ls" error.
Here is my code:
find /<dir1> -type f ls -lh >> snapshot.txt
find /<dir2> -type f ls -lh >> snapshot.txt

Any help or suggestions would be appreciated.
 
Old 07-24-2013, 12:16 PM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014.08, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 14,272

Rep: Reputation: 2662Reputation: 2662Reputation: 2662Reputation: 2662Reputation: 2662Reputation: 2662Reputation: 2662Reputation: 2662Reputation: 2662Reputation: 2662Reputation: 2662
Welcome to LQ.

May be you mean this ...

$ find /<dir1> -type f | ls -lh >> snapshot.txt
 
Old 07-24-2013, 12:22 PM   #3
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,154

Rep: Reputation: 333Reputation: 333Reputation: 333Reputation: 333
Or, perhaps

find /<dir> -type f -ls >> snapshot.txt

Example:
Code:
$ find ./ -maxdepth 1 -type f ! -name '.*' -ls
1969990   12 -rw-r--r--   1 Peter    Peter        9235 Oct  2  2012 ./conkyrc-wminfo
1969979   12 -rw-rw-r--   1 Peter    Peter       11126 Oct  2  2012 ./conkyrc-brenden.txt
1969989   16 -rw-rw-r--   1 Peter    Peter       14471 Oct  2  2012 ./conkyrc-vert.txt
1966156    4 -rwxrwxr-x   1 Peter    Peter         548 Feb 15 16:48 ./ttyinfo~
1970727    4 -rw-rw-r--   1 Peter    Peter         264 Oct 11  2012 ./PTrenholme.revoke
1969373  108 -rw-rw-r--   1 Peter    Peter      105922 Oct  2  2012 ./conky-dlab.tar.gz
1970737    8 -rw-rw-r--   1 Peter    Peter        6905 Oct 15  2012 ./random.txt
1970726    4 -rwxrwxr-x   1 Peter    Peter         209 Oct  8  2012 ./test.lua
1971139 1632 -rw-r--r--   1 root     root      1670597 Jan 16  2013 ./fedupdebug.log
1966130    0 -rw-rw-r--   1 Peter    Peter           0 Jul 14 16:23 ./libpeerconnection.log
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
find: paths must precede expression lead2gold Linux - General 11 02-27-2014 08:06 AM
[SOLVED] what does paths must precede expression means? sysmicuser Linux - Newbie 16 04-23-2013 05:40 AM
[GNU find version 4.2.27] find: paths must precede expression mechagojira Linux - Newbie 3 07-06-2011 06:34 AM
find: paths must precede expression -- already checked google/man/faqs escalf Programming 5 03-02-2010 11:12 AM
Problem with find: paths must precede expression troelskn Programming 11 07-29-2009 03:48 AM


All times are GMT -5. The time now is 04:00 PM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration