Search Results

Search: Posts Made By: VSom007
19,977
Posted By MadeInGermany
GNU Linux: if find "$dir" -prune -empty | grep...
GNU Linux:
if find "$dir" -prune -empty | grep -q .
then
echo "$dir is empty"
fi
19,977
Posted By apenkov
CNT=`ls $dir/* | wc -l` if [ $CNT -eq 0 ];...
CNT=`ls $dir/* | wc -l`
if [ $CNT -eq 0 ]; then
echo "There are no files in the dir"
else
echo "There are files in the dir"
5,494
Posted By Corona688
The reason that code doesn't complain about too...
The reason that code doesn't complain about too many arguments is because it does absolutely nothing at all, it doesn't run find, it doesn't expand *, nothing, nada, zip. *.* is a DOS thing by the...
19,977
Posted By balajesuri
if [ `ls | wc -l` -gt 0 ]
if [ `ls | wc -l` -gt 0 ]
19,977
Posted By clx
Please search. There are various threads stating...
Please search. There are various threads stating similar topic.

e.g. the one I found is here (https://www.unix.com/shell-programming-scripting/111106-check-empty-directory.html)
5,494
Posted By alister
I don't think there is any error message. The...
I don't think there is any error message. The first post states that find-xargs is used to avoid it and that the problem is preventing a descent into subdirectories.

I think this is a case of a...
5,494
Posted By MadeInGermany
But with find | xargs it's not the shell. ...
But with find | xargs it's not the shell.
Either xargs does not know the system limit or mv has a smaller limit than the system.
A work around is
xargs -n 50 ...providing at maximum 50 arguments...
5,494
Posted By alister
Minor nit: The parentheses are redundant. ...
Minor nit: The parentheses are redundant.

More importantly, the solution is incorrect. If ../<<Your Directory>> itself contains a directory named <<Your Directory>>, it will not be pruned since...
5,494
Posted By vidyadhar85
The shell can hold a maximum of 131072 bytes for...
The shell can hold a maximum of 131072 bytes for command line arguments. If you try to pass more than that number you will greeted with an error that read as follows:
Argument list too long...
5,494
Posted By MadeInGermany
You can do with GNU find find "directory1"...
You can do
with GNU find
find "directory1" -maxdepth 1 -type f | xargs -i mv {} "directory2"or with Unix find
find "directory1" \! -name "directory1" -prune -type f | xargs -i mv {}...
5,494
Posted By Skrynesaver
If I understand you correctly, you want to move...
If I understand you correctly, you want to move files in directory1 but not in sub directories into directory2?
for i in directory1/* ; do if [ -f $i ] ; then mv $i directory2/ ; fi; done
5,494
Posted By vidyadhar85
-maxdepth may not work sometime.. you can try...
-maxdepth may not work sometime.. you can try this alternate way


find ../<<Your Directory>> \( ! -name <<Your Directory>> -prune \) -type f | xargs -i mv {} "directory2"
Showing results 1 to 12 of 12

 
All times are GMT -4. The time now is 02:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy