Recipe: Splitting files and data split ===== $ mkdir split $ cd split $ dd if=/dev/zero bs=100k count=1 of=data.file 1+0 records in 1+0 records out 102400 bytes (102 kB) copied, 0.00056334 s, 182 MB/s $ split -b 10k data.file $ ls data.file xaa xab xac xad xae xaf xag xah xai xaj $ split -b 10k data.file -d -a 4 # Instead of k (kilobyte) suffix we can use M for MB, G for GB, c for byte, w for word etc. $ split -l 10 data.file # Splits into files of 10 lines each. csplit ====== $ cd server $ cat server.log SERVER-1 [connection] 192.168.0.1 success [connection] 192.168.0.2 failed [disconnect] 192.168.0.3 pending [connection] 192.168.0.4 success SERVER-2 [connection] 192.168.0.1 failed [connection] 192.168.0.2 failed [disconnect] 192.168.0.3 success [connection] 192.168.0.4 failed SERVER-3 [connection] 192.168.0.1 pending [connection] 192.168.0.2 pending [disconnect] 192.168.0.3 pending [connection] 192.168.0.4 failed $ csplit server.log /SERVER/ -n 2 -s {*} -f server -b "%02d.log" ; rm server00.log rm String slicing ============== $ file_jpg="name.jpg" $ file_name=${file_jpg%.jpg} #Means: remove wildcard appears after % from right side ( $ extension=${file_jpg#*.} # Means: show only wildcard appears from # from leftmost