for f in *; do cd $f; mv * ..; cd ..; rmdir $f; done

find . -type f ! -iname "*.mp4" ! -iname "*.jpg" ! -iname "*.wmv" ! -iname "*.mkv" ! -iname "*.mpg" ! -iname "*.avi" ! -iname "*.m4v"

sed 's#^#what to add to begging of line#' oldfile > newfile

sed 's#$#text to add to end of line#' oldfile > newfile

mkvmerge -o <output>.mkv –default-track 0 –language 0:eng <subtitles>.srt input

find . -iname "*files*" -type f -exec du -hsc {} +

find . -type f -exec basename {} \; | sed 's/\(.*\)\..*/\1/' | sort | uniq -c | grep -v "^[ \t]*1 "

find "location" -type f -exec rm {} \;

sed -i 's/original/new/g' file.txt

mkvmerge -o <output>.mkv –default-track 0 –language 0:eng <subtitles>.srt input.mkv

rm -r !(rm everything but this)

echo "`date +%F_%H-%M-%S` 'find "/data/"/ -iname "*.ts" -type f -exec du -hsc {} + | tail -1'" >> /root/test

youtube-dl -f 'bestvideo+bestaudio/best' –external-downloader=aria2c –external-downloader-args='–max-connection-per-server=16 –split=20′

xauth list $DISPLAY
xauth add "data from above"

# Remove beging characters of file names
for file in *ac3; do mv -v "$file" "$(echo $file | sed -e 's/^….//')"; done

ipmitool raw 0x30 0x70 0x0c 1 1 # shared

ipmitool raw 0x30 0x70 0x0c 1 0 # deditcated

grep -rnw 'location' -e 'test'

grep "^beggining of line to match" file

grep "end of line to match.$" file

# Create cert chain
cat .crt .ca-bundle >> _chain.crt

# Convert crt to pem
cat key > server.pem
cat crt >> server.pem
cat ca-bundle >> server.pem

# Create CSR
openssl genrsa -out [private-key-file.key] 2048
openssl req -new -key [private-key-file.key] -out [CSR-file.txt]

# create self signed cert
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout key -out crt

# View largest non active TV shows in Sonarr
sqlite3 /home/.config/NzbDrone/nzbdrone.db 'select Title, Status, round(sum(Size)/1024.0/1024.0/1024.0,2) from EpisodeFiles ef inner join Series S on S.ID = ef.SeriesID where status = 1 group by Title, Status order by sum(Size) ASC;'

# view network infro to pid
lsof -i -a -p pid

# View program and pid from port
netstat -nlp | grep :3000

# Prepend text to files
for f in *.md; do mv "$f" "test – $f"; done

# Make audio channel 2 default
find . -name "*.mkv" -exec mkvpropedit {} –edit track:a1 –set flag-default=0 –edit track:a2 # for subs –set flag-default=1 –edit track:s1 –set flag-default=0 –edit track:s2 –set flag-default=1 \;

# Only keep video stream and 2nd audio track
for f in *.avi; do ffmpeg -i "$f" -map 0:0 -map 0:2 -vcodec copy -acodec copy "new_$f"; mv "new_$f" "$f"; done

# Create system user
adduser –system –disabled-password –no-create-home –group user

# Rename Files
rename 's/old/new/' *.xxx

# Raise Volume for vid
ffmpeg -i inputfile -vcodec copy -af "volume=2″ outputfile

# Netstat processname name to port
netstat -putan | awk '/java/ {out=""; for(i=1;i<=6;i++){out=out" "$i}; split($7,result,"/"); system("ps aux | grep -v grep | grep " result[1] " >> x&"); getline < "x"; print out " " $14}'

# Kill other ssh sessions that aren't current
ps -ef | grep sshd | grep -v root | grep -v currentsshpid | grep -v grep | awk '{print "sudo kill -9", $2}' | sh
ps -ft pts/num

# Move all files in directory with only the first 26 characters on file. then append mp4 to the end of the file name
for i in *; do mv "$i" "$(echo $i | cut -c1-26)"; done && for i in *; do mv "$i" "$i.mp4"; done

# Create ssh key and transfer
ssh-keygen -t rsa
cat ~/.ssh/ | ssh [email protected] "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys"

# Remove leading spaces in files
rename -n 's/^ *//' *

# Show simularities in two files
fgrep -x -f file1 file2

# Generate index.html using tree
tree -H '.' -L 3 --noreport --charset utf-8 -P "*.mp4" > index.html
tree -H '.' -l -L 3 --noreport --charset utf-8 -T 'title' -P "*.mp4|*.m4v" > index.html

# POH for drives
for d in /dev/sd[a-z]; do printf $d; printf ' '; smartctl -a $d | grep Power_On_Hours; done

# Move running command to tmux
ctrl+z to pause
jobs -l
disown PID
reptyr PID

# kill stale ssh session. Run until there's no more in who
pkill -o -u root sshd

# Show data after ,
sed 's/.*,//'

# add file numbering to files
ls | cat -n | while read n f; do mv "$f" "$n.extension"; done

# use last argument

# Silent delete duplicate
fdupes -rdN dir/

# Convert XXX
for f in *.{wmv,avi,mov}; do echo ffmpeg -i "$f" -c:v libx264 -crf 23 -c:a aac -q:a 100 "$f.mp4"; done

# show encrypted rclone folder name
rclone -vv lsd --crypt-show-mapping location:

# move files to folders with same name
for fi in $(cat ../folders.txt); do mv "$fi"* "$fi"; done

# create folders from file
for as in $(cat folders.txt); do mkdir RENAMED/$as; done