User Tools

Site Tools


find_usage

This is an old revision of the document!


list files in chronological order

<some find command> | xargs ls -ltr --time-style="+%Y%m%d_%H%M"

For example, the following command will list all yml files under the current directory in a chronological order

find . -iname '*.yml' | xargs ls -ltr --time-style="+%Y%m%d_%H%M"

Sample run

$ find . -iname '*.yml' | xargs ls -ltr --time-style="+%Y%m%d_%H%M"
-rw-r--r-- 1 kkusuman 1049089  527 20191119_1013 ./envs/env_test_textract.yml
-rw-r--r-- 1 kkusuman 1049089  492 20191126_1044 ./envs/env_py36.yml
-rw-r--r-- 1 kkusuman 1049089  327 20200416_1807 ./envs/env_test_nbopen.yml
-rw-r--r-- 1 kkusuman 1049089  365 20200529_1848 ./envs/env_test_cherrypy.yml
-rw-r--r-- 1 kkusuman 1049089 1212 20210128_1851 ./envs/env_py38.yml
-rw-r--r-- 1 kkusuman 1049089  342 20210816_1802 ./envs/env_test_pyarrow.yml
-rw-r--r-- 1 kkusuman 1049089 2486 20211109_0907 ./envs/env_use_flask.yml
-rw-r--r-- 1 kkusuman 1049089 3130 20211231_1209 ./envs/env_py39.yml
-rw-r--r-- 1 kkusuman 1049089  645 20220607_0852 ./envs/env_play_ground.yml
-rw-r--r-- 1 kkusuman 1049089  354 20220607_0852 ./envs/env_test_pandas.yml
-rw-r--r-- 1 kkusuman 1049089 3153 20220609_1304 ./envs/env_py310.yml
-rw-r--r-- 1 kkusuman 1049089  698 20220722_1800 ./envs/env_rutils.yml

Ref:- https://stackoverflow.com/questions/11392526/how-to-sort-the-output-of-grep-l-chronologically-by-newest-modification-date/53438441

tags | find and sort, chronological, sort find results chronologically

find number of words in all files under a directory

gunzip files on nfs and copy to hadoop

files_to_copy=`find $dir -maxdepth 1 -iname '*.avro.gz' -newer $tmp_file -print
for i in $files_to_copy
do
    unzipped_file=${tmp_nfs_dir}/`basename $i | sed -e 's/\.gz$//'`
    gunzip $i -c > $unzipped_file
    hadoop fs -put -f $unzipped_file $hdfs_dir
    echo "$unzipped_file -> $hdfs_dir"
    rm -f $unzipped_file
done

tags | process the output of find

dummy

find and sort

find_usage.1704319081.txt.gz · Last modified: 2024/01/03 21:58 by raju