Skip to content

Latest commit

 

History

History
111 lines (101 loc) · 4.02 KB

random_stuff.md

File metadata and controls

111 lines (101 loc) · 4.02 KB

There are just few simple shell 1-liners I keep forgetting. Hopefully I don't get lazy to update this file after I google the things I need.

find and empty the contents of files:

find . -type f -exec truncate -s 0 {} \;

Take each line from a text file as an input (useful if you redirect the o/p of a find result to a file).

  • This MAY NOT escape special characters!

while read p; do ls -al "$p" ; done < list.txt

  • NOTE: Does not seem to work :(
WITHOUT_CHECK_API=true

screen -d -m <yourcommand>

Gerrit - search term to view all merged non-device related changes

status:merged -project:^LineageOS/android_device.+  -project:^LineageOS/android_kernel.+

RAR Archive folders with password in background:

for i in *NEF; do screen -d -m rar a -p'password' ~/Pictures/"$i.rar" -m0 -v500M -r "$i"/* ; done

find . -type f \( -name "*REAL*" -o -name "*FAKE*" -o -name "*mp3" \) -exec basename {} \;

find above and create replica dir structure from the result

  • Not tested against specal characters
 find . -type f \( -name "*REAL*" -o -name "*FAKE*" -o -name "*mp3" \) -exec dirname {} \; | xargs -I {} bash -c 'mkdir -p ./FAKES/"{}"'

find . -maxdepth 2 -mindepth 2 -type d | sort | sed 's:./::;s:/:",":;s:^:":;s:$:":g;' > file.csv

sed -r -i 's/^\[(.*)\]//' "$FILE"

^(.*)(\r?\n\1)+$

Substitute find result as argument in a command and run it in background

find -iname "*flac" -exec ls -Q {} \; | sed 's/$/ \&/; s/^/md5sum /' > ~/tmp/bg_tasks.sh
 sed '0~10 s/$/\nwait\necho WAITING.../' < bg_tasks.sh > waiting_tasks.sh

find \( -name "*lrc" -o -name "*flac" \) | sed -e "s/.flac$//g;" -e "s/.lrc$//g;" | sort | uniq -u

awk -F '[[:space:]][[:space:]]+' ' $1~/TIMEST/ { print } { print $5 }' /tmp/netstat_connections.txt | head

^(ID|[0-9]+)\t+([\x00-\x7F]|[^\x00-\x7F])(.*?)\t

Example:
ID			artist	title	error
91092377	Seether	I've Got You Under My Skin	Your account can't stream the track from your current country and no alternative found.

Matches till BEFORE the TITLE column 

NX Tar extract manually collected bundles and strip unnecesarry folders:

for i in *tar.gz; do j="${i%.tar.gz}"; mkdir $j; tar -C $j -xf $i --strip-components=4; done

awk '/### begin/ {seen = 1} seen {print}' wg0.conf

$ git log --oneline COMMIT~1..COMMIT | awk '{first = $1; $1 = ""; print $0, first; }'
 <COMMITmessage> <commitsha>