Find command take too long


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find command take too long
# 8  
Old 08-24-2015
Quote:
Originally Posted by MadeInGermany
When piped to a text processor like sed then the file name should be in quotes:
Code:
find . -type d -print | sed "s/.*/mkdir -p '&'/"

Sorry, but this is not the case. "&" is the metacharacter for "everything matched by the regexp in the search part". In this case it is everything matched by ".*", which is the whole line.

The way i wrote it it was single-quoted and hence already protected by the shell. The way you wrote it as a seemingly single-quoted string inside a double-quoted string it is not correct any more because single quotes lose their special meaning inside a quoted string. For instance: echo "this is a ' inside a double-quoted string" will display the single-quote like a normal character whereas echo 'this is a " inside a single-quoted string' will treat the double-quote as normal character and the single-quotes as string delimiters.

The reason is that the shell maintains just one flag "inside quoted string", which is either TRUE or false. Once a (single- or double-) is encountered this flag is switched and only switched back when a second matching (and not escaped) is found. Other quote-chars are ignored (or, respectively, treated as normal characters) during this time.

Having said this it is probably better to rephrase the sed-command this way:

Code:
find . -type d -print | sed  's/^/mkdir -p /; $ s/$/; chmod -R 777 */' > script.sh

I hope this helps.

bakunin
# 9  
Old 08-25-2015
Yes, not needed in this script.
But the intention is to run the output as another script; therefore the additional 'quotes' make sense.
These 2 Users Gave Thanks to MadeInGermany For This Post:
# 10  
Old 08-25-2015
Quote:
Originally Posted by MadeInGermany
Yes, not needed in this script.
But the intention is to run the output as another script; therefore the additional 'quotes' make sense.
Ahh, now i get it. You are right, this was a good addition.

bakunin
# 11  
Old 08-25-2015
It would be quicker just to get the list of directories and send that to the new server, then loop to do the creations there.

I would also change it to use the -m flag on the mkdir, negating the need for a chmod

You could also use tar if you have a way to exclude files (AIX has the -L flag that may help) to use perhaps fsdump & fsrestore; ufsdump & ufsrestore; or backup & restore

If you use the restore interactively, you can get the structure as is and then abort the actual data restore.


There are probably lots of other options too, like the cpio one above.

Robin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find command takes long

Hi, I am trying to search for a Directory called "mont" under a directory path "/opt/app/var/dumps" Although "mont" is in the very parent directory called "dumps" i.e "/opt/app/var/dumps/mont" and it can never be inside any Sub-Directory of "dumps"; my below find command which also checks... (5 Replies)
Discussion started by: mohtashims
5 Replies

2. UNIX for Advanced & Expert Users

Find command takes too long to complete

Hi, Below is my find command find /opt/app/websphere -name myfolder -perm -600 | wc -l At time it even takes 20 mins to complete. my OS is : SunOS mypc 5.10 Generic_150400-09 sun4v sparc SUNW,T5440 (10 Replies)
Discussion started by: mohtashims
10 Replies

3. Shell Programming and Scripting

find only 6 char long

find /tmp -type f -mtime +180 I have this script get the list to clean up files older than 180 days under /tmp. But, I want to make sure to grep only a type of files, which have only 6 character long. .... LT3hqa dRMoya ... (16 Replies)
Discussion started by: Daniel Gate
16 Replies

4. Shell Programming and Scripting

find 3 character long text

I was trying to do some experiment with "sed". I want to find the filenames which are three characters. So, this is what I have done to search for it, using sed. sed -n -e '/^\{3\}$/p' test This returns the correct output for characters. But if I make change, let's say i create 2 more... (4 Replies)
Discussion started by: aksijain
4 Replies

5. Solaris

How to find out bottleneck if system is taking long time in gzip

Dear All, OS = Solaris 5.10 Hardware Sun Fire T2000 with 1 Ghz quode core We have oracle application 11i with 10g database. When ever i am trying to take cold backup of database with 55GB size its taking long time to finish. As the application is down nobody is using the server at all... (8 Replies)
Discussion started by: yoojamu
8 Replies

6. Shell Programming and Scripting

Find and rename long file names (html)

Hi Guys, I need a help. I have 1130 zip files. Each one of them has files including 1 html file with long file name (includes special charactors, Alphabetic and numbers). I have copied all 1130 zip files to my linux system and extracted using below command. Find . -name "*.zip" -exec... (7 Replies)
Discussion started by: Rajmani
7 Replies

7. UNIX for Dummies Questions & Answers

Long listing of files using find command on remote server via SSH

Hi , I am trying to find some files on a remote machine using the find command. >ssh -q atukuri@remotehostname find /home/atukuri/ -name abc.txt /home/atukuri/abc.txt The above command works fine and lists the file, but if I want to do a long listing of files (ls -l) its not working . ... (2 Replies)
Discussion started by: atukuri
2 Replies

8. Shell Programming and Scripting

Help with find command and list in a long format each found file

The purpose of those comands are to find the newest file in a directory acvrdind to system date, and it has to be recursively found in each directory. The problem is that i want to list in a long format every found file, but the commands i use produce unexpected results ,so the output lists in a... (5 Replies)
Discussion started by: alexcol
5 Replies

9. Shell Programming and Scripting

Find/Change long text

If I have very large text file *************** *************** *************** *************** *************** ABC-sdfsdf BBB-xk[ptr'; CCC-sdfolb ABC-dltg'fl;l My aim: -> tail last 10 lines from large text. ***** Ok ***** -> Change first 3 charactors which begin with "ABC" to "abc".... (1 Reply)
Discussion started by: aungomarin
1 Replies

10. Shell Programming and Scripting

command find returned bash: /usr/bin/find: Argument list too long

Hello, I create a file touch 1201093003 fichcomp and inside a repertory (which hava a lot of files) I want to list all files created before this file : find *.* \! -maxdepth 1 - newer fichcomp but this command returned bash: /usr/bin/find: Argument list too long but i make a filter all... (1 Reply)
Discussion started by: yacsil
1 Replies
Login or Register to Ask a Question