Can`t get the find command`s -exec working. (Solved)

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

Can`t get the find command`s -exec working. (Solved)

#1 Post by sunburnt »

I need to replace just the files in /lib with links.
I wrote this test command to try it out:

Code: Select all

find /lib -type f -exec echo /mnt/sq/{} /{} ;
The real command looks like this:

Code: Select all

find /lib -type f -exec ln -s /mnt/sq/{} /{} ;
Reported error is... find: missing argument to `-exec
I tried escaping the brackets, like /mnt/sq/\{\} /\{\} , but no good.
The first part of the command is good and gives just the files in /lib.

Code: Select all

find /lib -type f
A squash file is mounted at /mnt/sq and has a duplicate /lib dir. in it.
The new links in /lib point to the files in the squash file at /mnt/sq/lib

I originally wanted to just replace the dir. /lib with a link, but no go.
The link command executes and the error code is 0, but no change.
The new /lib link still points to the same original dir. as before. Odd...

I guess you can replace files that`re in use, but not dirs. with open files.
I`m guessing that files in /lib are used right after the root fs is extracted,
which leaves no time to make changes before /lib is tied up.
Last edited by sunburnt on Wed 24 Aug 2011, 20:08, edited 1 time in total.

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#2 Post by amigo »

It's escape the semi-colon:
find -type f -exec echo /mnt/sq/ {} \;
and space before the brackets, although I can't see what you are trying to accomplish with that.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#3 Post by sunburnt »

Thanks amigo, you`ve been lots of help for a long time now!

The command you posted is the test, the real command moves /lib (essentially).

amigo... A question if I could:
I tried renaming /lib to /lib_ and made a link to it /lib
But when I tried creating a link over the top of /lib to redirect it, Nothing.
The error code from the link command was 0, but it still pointed to /lib_

As I said, it seems individual files and links can be "linked over", but not dirs.
I tested it, made a dir. /0 and made a link with it`s name pointing to another dir.

Code: Select all

ln -s boot 0
It made a link inside the dir. with the name of the dir. it pointed to... /0/boot
It seems links can be created over links and files, but not dirs.

Can you think of a way to make /lib into a link pointing to /lib in a squash file?

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#4 Post by sunburnt »

Got it... The command "ln -sfT" will do it. The "T" sets the links target.

Thanks again amigo... Terry

Post Reply