All Questions
19 questions
0
votes
0
answers
52
views
Move directory contents up one level only if it contains files
How to I move directory contects up one level only if it contains files. Some hints would help. Thanks!
Example to move up one level:
├── AAA
│ └── AAA1
│ ├── 001.jpg
│ ├── 002.jpg
│ ...
1
vote
1
answer
138
views
How to move a set of files and directories, excluding another (sub-)set
I have two bash arrays, one of them (named toMove) contains paths to files and directories to move (not copy) somewhere else, and the other one (named exclude) contains paths to files and directories ...
1
vote
1
answer
2k
views
Readable format of file sizes using the Find command
To see human readable output, I can use the following command –
du command -h option : Display sizes in human readable format (e.g., 1K, 234M, 2G).
$ du -hsx * | sort -rh | head -10
The sample output ...
0
votes
1
answer
242
views
Using find with sh command not working - further queries
Further to the earlier query posted
Using find with sh - command not working
find . -type f -name '*FW*' -exec grep -iEq 'chmod.*archive|archive.*chmod' {} \; -ls
This cmd was not able to find the ...
0
votes
1
answer
36
views
How to pass found files repeatedly to be sourced by script
I am finding files that do not end with .done like so:
find -type f -not -name \*.done -execdir myscript {} \;
Now, what I want to do is the following:
-pass each found file to myscript
-source ...
1
vote
2
answers
655
views
piping output of find command
Further to my query posted -
Using find with sh - command not working
Based on the o/p of the below command I need to update the permission to 777 for each of the files that are listed.
find . -type ...
2
votes
3
answers
1k
views
Using find with sh - command not working
I am trying to search for files that have pattern FW.
From these filtered files I am trying to search for pattern chmod.*archive|archive.*chmod, then list them.
I tried with the below command, but ...
0
votes
2
answers
551
views
How to sort videos by codec and execute a command
So I have been trying filter out H265/HEVC and only show videos that are not the previous codec and then execute a command that I have that will transcode the video using my settings.
Every time I ...
1
vote
3
answers
3k
views
find a file through particular search in while loop [closed]
Actually it is related to my previous post sorting out directories by searching certain file extension which is still unanswered. There are many options available to solve the problem, but I am ...
8
votes
2
answers
5k
views
Manipulate {} return string from find -exec
I want to do it as efficient as possible in case there will be a lot of files.
What I want is rename all the files I found and remove their suffix.
For example:
[/tmp] $ ls -l
a.log
b.log
c.tmp
[/...
2
votes
3
answers
2k
views
Asking Bash to cd into each directory under some path and run a command when it is inside?
Take this path for example: /var/www/html.
Inside the dir html, there are a few subdirectories. I need the system to go into each one of these sub-directories via cd (it must be cd), and then running ...
-4
votes
1
answer
43
views
find problems again? [closed]
How do i show pipe or socked files from a directory?
echo "give name of directory: "
read directory
if [ -d "$directory" ]
then
echo "thanks again"
else exit
fi
find $directory -maxdepth 1 -type ...
1
vote
3
answers
5k
views
Bash script for automatic tar backup of chosen files and directories
Within a given directory in linux environment, I need to pick all files modified after a certain date (let's say 7 days) as well as all directories (only in root directory, hence non recursively) ...
6
votes
6
answers
2k
views
Delete all files in directories except those whose path are listed in a file
Given the following files:
data/A/a.txt
data/B/b.pdf
...
date/P/whatever.log
...
data/Z/z.jpg
I would like to delete all files in the data/A/, data/B/, ..., data/Z/ directories except those files ...
2
votes
2
answers
2k
views
Optimized way to list and delete files
I need to list and delete .php, .xml files. For this I am using find command.
To list :
find . -type f -name \*.php -print0
To delete :
find . -type f -name \*.php -print0 | xargs -0 rm -r
As I run ...