Tag Info

Hot answers tagged


find -type d -name b -exec echo "mv {}/* {}/..; rmdir {}" \; | sh


Are you sure the process was in the foreground?  Just because it was writing output to the terminal does not mean it was in the foreground. If you have a command that produces output, and you want to run it in the background, you should redirect the output, as: find / -name .bash_profile > find_results & It is normal for background process to be ...


It is indeed running in the background and you can do other things, but anytime it outputs something, it outputs to your current terminal. Suggestion: find / -name .bash_profile >my_result.txt 2>/dev/null & This saves the output to a file, and discard all errors (such as permission denied error). You can check the status by either peeking in the ...


Easy. Just pipe the output of the lsof command into grep for further processing like this: sudo lsof | grep /path/of/directory/you/care/about


You've stumbled on a pet peeve of mine with find. Try using the -print option like so find / -name '.bash_profile' -print > some_file You also may be running into an issue by not escaping or single-quoting the dot in the filename. find supports RegEx syntax so that dot in the filename could be misinterpreted. Either of the examples below should ...


You would need to maintain the iteration separately. For example, use a script move_count containing the following:- [ -w ~/MoveCount ] || echo 0 >~/MoveCount read count <~/MoveCount ((++count)) echo $count >~/MoveCount mv "$1" "$count.${1##*.}" Then your find command would become: find -iname "*.jpg" -exec bash -c "move_count {}" \; Note that ...

Only top voted, non community-wiki answers of a minimum length are eligible