Skip to content

Instantly share code, notes, and snippets.

@arttuladhar
Last active February 13, 2023 02:18
Show Gist options
  • Save arttuladhar/98a8b8e9c684292055d8cb4a768c7e64 to your computer and use it in GitHub Desktop.
Save arttuladhar/98a8b8e9c684292055d8cb4a768c7e64 to your computer and use it in GitHub Desktop.
Handy Linux Commands

Some handy Linux command line tricks

Delete All JSON files in a directory

for files in *.json; do rm "$files"; done

Scp Multiple Files

for files in *.json; do scp "$files" 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/Tar 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

Find 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

Using Sequence

for i in `seq -w 0 10`; do echo "Hello $i"; done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment