bash/zsh one-liners
1. Slicing files
Slice a file into pieces and put it back together. Useful if you need to meet file size limits.
This code splits a file named 'largefile.zip' into pieces of size 1500M = 1.5GB.
It names these chunks 'largefile_chunk_aa', 'largefile_chunk_ab', and so on, and these are files of the specified size.
The very last chunk's size will be the remaining bits of the file after all other chunks are made.
split -b 1500M largefile.zip largefile_chunk_
Now, put it back together with 'cat' by feeding them into the command in the order the were generated.
cat largefile_chunk_aa largefile_chunk_ab > largefile.zip
cat largefile_chunk_* > largefile.zip
You should now have your original file back.
2: Zip folder + exclude files
Specify which files to exclude when zipping a folder. Useful for removing hidden files or .DS_Stores on Mac.
This code creates a zip file of the directory 'folder_name' and names it 'folder_name.zip' while excluding any instances of .DS_Store in the zip.
zip -r folder_name.zip folder_name -x "*.DS_Store"