LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-18-2017, 11:16 AM   #1
JockVSJock
Senior Member
 
Registered: Jan 2004
Posts: 1,420
Blog Entries: 4

Rep: Reputation: 164Reputation: 164
find command fails with the following error: paths must precede expression: sort


I'm automating a number of things that person was doing manually who has left the organization.

That person was running the following daily to a log file to show what files have been created by a piece of software.

Code:
find /path/to/data -mtime -1 -type f -exec stat -c "%n %y" {} \; sort >> /home/user/log.txt &
When I run the whole find, -exec and sort command, from the CLI first, I' getting the error message:

Code:
find:  paths must precede expressions:  sort
When I back it off, the find and -exec will run correctly, there is something with the sort that is causing the issue

Code:
find /path/to/data -mtime -1 -type f
find /path/to/data -mtime -1 -type f -exec stat -c "%n %y" {} \;
Took the error message and a couple of hits in the search engine (Stack Exchange) shows that an argument needs to be quoted with single quotes, except I'm not sure what needs to be quoted. I tried to single quote the sort part, however that didn't work. Not sure what the issue is.

thanks

Last edited by JockVSJock; 12-18-2017 at 11:29 AM.
 
Old 12-18-2017, 11:30 AM   #2
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Why not just pipe find output to sort?
Code:
find .... | sort
 
2 members found this post helpful.
Old 12-18-2017, 11:34 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,838

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
there is no such argument (sort), therefore it is taken as path. But paths must precede expressions...
I assume sort is used to sort the result of find, therefore post #2 is the right solution. Looks like the original command you posted is incorrect.
 
Old 12-18-2017, 01:34 PM   #4
JockVSJock
Senior Member
 
Registered: Jan 2004
Posts: 1,420

Original Poster
Blog Entries: 4

Rep: Reputation: 164Reputation: 164
Quote:
Originally Posted by keefaz View Post
Why not just pipe find output to sort?
Code:
find .... | sort
Ya, I missed the | . Once I put that in, it fixed the issue.
 
  


Reply

Tags
find sort -exec



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 Off
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 07:06 AM
[SOLVED] Bash Issue with Find Script: find paths must precede expression: *.txt JockVSJock Programming 4 01-06-2014 09:03 PM
find: paths must precede expression: ls HELP! wdtunstall Linux - General 2 07-24-2013 11:22 AM
[GNU find version 4.2.27] find: paths must precede expression mechagojira Linux - Newbie 3 07-06-2011 05:34 AM
Problem with find: paths must precede expression troelskn Programming 11 07-29-2009 02:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:19 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
Open Source Consulting | Domain Registration