Skip to content

Instantly share code, notes, and snippets.

@NISH1001
Last active March 27, 2020 02:02
Show Gist options
  • Select an option

  • Save NISH1001/69ce313ce7cbd5c4195b6a7023a4ff77 to your computer and use it in GitHub Desktop.

Select an option

Save NISH1001/69ce313ce7cbd5c4195b6a7023a4ff77 to your computer and use it in GitHub Desktop.
linux command

Sort Filenames by Size

du ./ | sort -n -r | head -n 20

Search string in files

grep -rnw -e "string" .

Sort Files by number of lines they contain

wc -l * | sort -rn

Average File Size

du -sb * | awk ' { sum+=$1; ++n } END { print sum/n/1024 } '

Execute A Command Timely

watch -n 5 "python test.py"

This will execute test.py every 5 seconds and prints out the output.

Test

python eval.py eval-overall /home/paradox/Nish/Programming/Python/conda-shit/docsumo/gitlab/image-preprocessing/output/responses/17-dec/17-dec-response.pkl | grep -oP -- "^[^IMG_].*\+\d+" | awk '{print $1;}' | sed 's/^/\/home\/paradox\/data\/docsumo\/bs-images\//' > tmp/good.txt

Test 2

python eval.py eval-overall /home/paradox/Nish/Programming/Python/conda-shit/docsumo/gitlab/image-preprocessing/output/responses/17-dec/17-dec-response.pkl | grep -oP -- "^[^IMG_].*\+\d+" | awk '{print $1;}' | sed 's/^/\/home\/paradox\/data\/docsumo\/bs-images\//' | while read file ; do cp "$file" "/home/paradox/data/docsumo/bs-images/new/"; done

Symlink

Softlink

ln -s /path/to/original/file /path/to/target/file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment