It is currently Wed Jun 19, 2013 10:35 am

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: different behavior of 'find' command
PostPosted: Thu May 24, 2007 1:58 pm 
Master of the known universe
Master of the known universe

Joined: Fri Mar 10, 2006 7:57 am
Posts: 765
Location: Sundbyberg, Sweden
Not necessarily a bug, more of a 'feature'

the combination of 'bash' and 'find' works a little differently with this new release.

In 4.4 i could enter this find command and get the expected result:
Code:
root[etc]# find ./ -name *.new -print
./ssh/sshd_config.new
./samba/smb.conf.new
./shadow.new
./group.new
./passwd.new

tying the same on a 4.6 machine yields:
Code:
root[etc]# find -P ./ -name *.new -print
find: paths must precede expression
Usage: find [-H] [-L] [-P] [path...] [expression]

Instead i must escape the "*" like this
Code:
root[etc]# find -P ./ -name \*.new -print
./rc.d/rc.wireless.new
./rc.d/rc.6.new
./rc.d/rc.M.new
./rc.d/rc.rpc.new
./rc.d/rc.wireless.conf.new
./rc.d/oldcf/rc.wireless.conf.new
./ssh/sshd_config.new
./samba/smb.conf.new
./modprobe.d/blacklist.new
./inittab.new
./shadow.new
./group.new
./passwd.new


why is it like this?

This breaks some of my scripts  >:(

_________________
Ursvik

"In the end, to achieve happiness,  all you need to know is the url to the latest Zenwalk ISO. "


 Profile Send private message  
 
 Post subject: Re: different behavior of 'find' command
PostPosted: Thu May 24, 2007 10:10 pm 
Dev team
Dev team

Joined: Mon Apr 24, 2006 2:01 pm
Posts: 844
Location: UK
ursvik wrote:
This breaks some of my scripts  >:(

Your scripts were already broken ;D.  The shell expands *.new to a list of matching filenames, then find cries because it expected only one pattern after -name (unless there was only one match anyway). You can get the output of your first example if you turn off the shell globbing: set -o noglob

Maybe you did this before?

Quoting as "*.new" is better, because explicit beats implicit (or indeed, escape the special characters).

My 4.4 is no different to snapshot in this:
Code:
markc[testfind]$ cat /etc/zenwalk-version
Zenwalk 4.4
markc[testfind]$ find ./ -name *.new -print
find: paths must precede expression
Usage: find [-H] [-L] [-P] [path...] [expression]


cheers  ...  markc

_________________
Zenwalk with me


 Profile Send private message  
 
 Post subject: Re: different behavior of 'find' command
PostPosted: Fri May 25, 2007 12:56 am 
Regular Zenwalker
Regular Zenwalker

Joined: Sat Apr 21, 2007 7:55 pm
Posts: 41
pedantic  point, but -print is the default option and you don't need to type it.  I'm incredibly lazy so I don't type anything I don't have to


 Profile Send private message  
 
 Post subject: Re: different behavior of 'find' command
PostPosted: Fri May 25, 2007 6:56 am 
Master of the known universe
Master of the known universe

Joined: Fri Mar 10, 2006 7:57 am
Posts: 765
Location: Sundbyberg, Sweden
markc wrote:
Your scripts were already broken ;D

I decide that  ;D 

They work in sco unix though  ;)

I suppose i could concur... escaping IS backwards-compatible ...

oliver_cfc wrote:
pedantic  point, but -print is the default option and you don't need to type it.  I'm incredibly lazy so I don't type anything I don't have to


i've been doing it like that for 11 years now, and i'm too lazy to re-learn  :D
I work with several flavors of unix + linux daily, so i tend to learn commands in a way that work for all. I don't remember where 'find' does not have -print as default, but there must be somewhere  :P


Edit :
The reason i discovered this is that i happened to be executing find in a directory where there were matching files, i (and many, many more, i trust) normally use ls to find files in a directory  8)

_________________
Ursvik

"In the end, to achieve happiness,  all you need to know is the url to the latest Zenwalk ISO. "


Last edited by ursvik on Fri May 25, 2007 7:32 am, edited 1 time in total.

 Profile Send private message  
 
 Post subject: Re: different behavior of 'find' command
PostPosted: Fri May 25, 2007 1:20 pm 
Regular Zenwalker
Regular Zenwalker

Joined: Sat Apr 21, 2007 7:55 pm
Posts: 41
ursvik wrote:

i've been doing it like that for 11 years now, and i'm too lazy to re-learn  :D


it took me a while to get out of the habit of typing:

gunzip -c | tar xvf -

:-)


 Profile Send private message  
 
 Post subject: Re: different behavior of 'find' command
PostPosted: Tue May 29, 2007 6:27 am 
Master of the known universe
Master of the known universe

Joined: Fri Mar 10, 2006 7:57 am
Posts: 765
Location: Sundbyberg, Sweden
don't laugh, i still do that... It is even worse the other way around, when you are on some AIX system and can't figure out why 'tar -xvfz arcanoid.tar.gz ' won't work

_________________
Ursvik

"In the end, to achieve happiness,  all you need to know is the url to the latest Zenwalk ISO. "


 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


 Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: