I have been able to create the following command, which works to an extent:
find . -type d -name "thumbs" -delete
However, it only deleted the empty folders. If it found a folder called 'thumbs' that wasn't empty, it didn't delete it.
How can I find all folders called 'thumbs' and delete them, including their contents?
Found the answer! Use the following (with caution):
find . -type d -name "thumbs" -exec rm -rf {} \;
Related
I have a linux server from which i need to download files(zip) to my local machine that is generated for a particular filename using scp and find command, my filename syntax is like this
WSB_20230105_20230106_052320.zip.bz2 ,i need to download only the files with filenames containing "20230105".
I have tried thisĀ
find . /app/weblogic/etsitf1/prestige/outbound/mis -type f -name "_20230105_20230106" -exec scp {} /tmp/tmp_dat_files \
which is not working for me . Please help
Thank you
How do I copy all the folder, subfolders and files permissions (recursively) from /www_03062018 to my new /www ?
I came across this post: https://superuser.com/questions/625673/clone-permissions-for-all-files-in-a-folder
chmod --reference=RFile file
Which didn't help much, it did apply a change for the main folder /www but didn't apply on its subfolders and files.
i have tried:
chmod -R --reference=/www_03062018 /www
and it didn't work.
My situation:
I have 2 folders on my Ubuntu machine: /www and /www_03062018.
/www is a "git clone" from the production machine.
/www_03062018 is my old directory that i used to work on and upload files via FTP.
I started to use GIT and when I clone a directory - all its folder ownerships and file accesses settings doesn't get cloned too.
cd to the new directory which you want to give new permissions - in my case:
cd /www
For CHMOD this worked:
find . -path ./.git -prune -or -exec chmod --reference '/www_03062018/{}' '{}' ';'
And for CHOWN this worked:
find . -path ./.git -prune -or -exec chown --reference '/www_03062018/{}' '{}' ';'
Hope this helps others :) !
#!/bin/bash
# create a list of checksums
cat /dev/null > MD5SUM
for i in */*/*.sql ; do test -e $i && md5sum $i >>MD5SUM ; done
Then this command is used to check to see if anything has changed:
md5sum -c MD5SUM
It works fine and everything. I just don't really understand how. Say if I wanted to make a checksum list of all the files in my home directory $HOME how can I do that? What does the */*/*.sql part of the for loop mean? I'm assuming that is to display SQL files only but how can I modify that? Say I wanted all files in the directory? Why is it not just *.sql ? What does the rest of the for loop do in this case?
Lets go by parts:
cat /dev/null > MD5SUM
this will only "erase" the previous MD5SUM file/list that was created before.
for i in */*/*.sql;
this will iterate over files that are 2 directories deep from your current folder. If you have folders
~/a/b
~/c/d
~/e/f
and you run your script in your home folder (~) all "*.sql" inside directories b,d,f will have the checksum calculated and piped to a file MD5SUM in the current direcotry:
do test -e $i && md5sum $i >>MD5SUM ; done
Now Answering your questions:
Say if I wanted to make a checksum list of all the files in my home directory $HOME how can I do that?
I would use the find command with the exec option
find $HOME -maxdepth 1 -name \*.sql -exec md5sum {} \;
What does the //*.sql part of the for loop mean?
I answered it above, anyway only goes 2 directories deep before getting to the files.
I'm assuming that is to display SQL files only but how can I modify that? Say I wanted all files in the directory?
Change
for i in */*/*.sql;
to
for i in */*/*;
or for current directory
find $HOME -maxdepth 1 -name \* -exec md5sum {} \;
Why is it not just *.sql ? What does the rest of the for loop do in this case?
Explained before.
Hope it helps =)
I am trying to write a bourne-shell script that takes a string as a parameter and deletes all files in the directory containing that string
I was thinking about using find and execute rm all but I just started b-shell
find . -name $1 'core' -exec rm -i* {}\;
any help would be much appreciated. thanks.
Why not just this:
#!/bin/sh
rm *$1*
Removes files in the current directory that contain your argument.
remove.sh script:
#!/bin/sh
find . -type f -iname *$1* -exec rm -rf {} \;
usage:
$remove.sh "main"
I am trying to write a simple command that searches through a music directory for all files of a certain type and copies them to a new directory. I would be fine if the files didn't have spaces.
I'm using a script from the following question, but it fails for spaces:
bash script problem, find , mv tilde files created by gedit
Any suggestions on how I can handle spaces, once I'm satisfied that all the files are being listed, I'll change echo to cp
for D in `find . -name "*.wma*"`; do echo "${D}"; done
You probably want to do this instead:
find . -name *.wma -exec echo "{}" \;