Tag Info

New answers tagged


Here's a Windows batch solution (may be a time consumpting one): @ECHO OFF >NUL @SETLOCAL enableextensions disabledelayedexpansion for %%G in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do ( if exist %%G:\NUL ( echo %%G: drive for /F "tokens=*" %%H in ('where /r %%G:\ rand.txt 2>NUL') do ( echo %%H ...


This should do it in Powershell: gwmi Win32_LogicalDisk | Select-Object -expand DeviceID | %{$drive = $_; $drive; ls "$drive\rand.txt" -recurse | %{ii (Split-Path $_)}}


Recommended usage: find ... -print0 | xargs -0 ... ... if you say -print0 for find, then you need -0 for xargs. For what it is worth, I often find xargs a nuisance - in those cases I take care to build the exact commands I want to execute with find -printf and then finally append | bash to it.


Ok done ! I didn’t know how to use prune argument. This respond to my demand find * -path "*/files/*" -prune -o -name 'foo' -type f -print More explication here On the other hand I should be curious if there is a syntax with the ! (NOT) argument like in this example on AskUbuntu if someone have an idea.


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 ...


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


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


Here are a few things wrong: Try not to iterate over or pipe output produced by ls into another tool. It will break if files contain whitespace or newlines, depending on how the command is constructed. In your case, however, there's no easy way to accomplish what you want other than using ls. So if you know that your file names will not contain a newline, ...


What about: for each in `ls -rt log.*.gz`; do zgrep "<TREASURE>" $each; done

Top 50 recent answers are included