Tag Archives: unix

Feed unix pipe into ls / feed ls with pipe

To feed “ls” instruction with pipe, simply use xargs as per below: find . -type f -name mypattern* | xargs ls -l sources http://stackoverflow.com/questions/18210956/unix-pipe-into-ls

Unix – find files modified on a specific date / between two dates

“find” command is our friend here, using “-newer” argument. This is a 2-step process: create reference file(s) with required date limit(s) run find command with reference to this/these file(s) find all files modified after 2015/12/15 6:51pm and 2 seconds touch -t 201512151851.02 /tmp/t find . -newer /tmp/t find all files modified between two dates touch -t <date1> /tmp/t1 touch -t <date2> /tmp/t2 find . -newer /tmp/t1 -and -not -newer /tmp/t2 sources http://stackoverflow.com/questions/158044/how-to-use-find-to-search-for-files-created-on-a-specific-date

/bin/cp: cannot execute [Argument list too long] – [solved]

When executing simple command line statements such as rm, cp or ls on a folder containing large number of files, following error is thrown: cannot execute [Argument list too long] Workaround this issue is to use the “find” process along with “-exec” argument, as per below example on copy statement: find <src_path> -name “*.xml” -exec cp “{}” <destination_path> \; note: replace “cp” with “rm” or whichever command failing due to large number of entries. sources http://stackoverflow.com/questions/11289551/argument-list-too-long-error-for-rm-cp-mv-commands http://stackoverflow.com/questions/143171/how-can-i-use-xargs-to-copy-files-that-have-spaces-and-quotes-in-their-names

unix – count number of files inside a folder

Simply run following command line: ll *.xml | wc -l in above example, we are counting number of files ending with .xml => feel free to adapt this query