Skip to content

Latest commit

 

History

History
24 lines (23 loc) · 958 Bytes

working_with_files.md

File metadata and controls

24 lines (23 loc) · 958 Bytes

Working With Files

Create a 5GB file containing nulls
dd if=/dev/zero of=file.txt count=1024 bs=5048576

Splitting a big binary file into parts (and assembling them again)
split -b 10M home.tar.bz2 "home.tar.bz2.part"
assemble again: cat home.tar.bz2.parta* > backup.tar.gz.joined

Copy a file to another location on the same server and limit the disk i/o
rsync --bwlimit=500k output003.flv temp

List folder contents in one column
ls -alt --format=single-column

Find size of each directory and output the directory name and disk usage only
find ./ -type d -maxdepth 1 -exec du -h -d 1 {} \;

Pretty-print JSON output from a script
./output_some_json.sh | python -m json.tool

sed-based find and replace recursive
find ./ -type f -exec sed -i 's/https:\/\/domain\.com/https:\/\/www.domain.com/g' {} +