arttuladhar
5/13/2017 - 12:44 AM

Linux Command Line Hacks

Linux Command Line Hacks

Some Handy Linux Command Line Tricks

#### Delete All JSON files in a directory
for f in *.json; do rm "$f"; done

#### Scp Multiple Files
for f in *.json; do scp "$f" art@art-server:/apps/art/data/app/json/.; done

#### Create Split Zip Archive
zip -r -s 100m ArchiveName.zip FolderName

#### Join Split 
zip -s0 ArchiveName.zip --out new.zip

#### Set TimeZone
timedatectl set-timezone America/Chicago

#### Zip Each File Individually
find . -name '*.csv' -exec zip '{}.zip' '{}' \;
find . -name '*.csv' -exec tar -zcvf '{}.tgz' '{}' \;

### Add Line to Top of File
{ echo -e 'Line 0'; cat file; } > file1

### Largest File Under Directory
du -a * | sort -r -n | head -10

#### Cut CSV Fields to Different File
cut -f 1,3domains-group -d , 000000_0 > update_000000_0

### Compress Director
tar -zcvf compressFileName.tar.gz folderToCompress

### Issuing Remote Commands over SSH
user=art
ip=192.168.1.1
command="cat"

ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $user@$ip $command