Some basic linux hacks

#Sharing files on local server:

sender:target dir$ python3 -m http.server port
receiver$ wget -r sender_ip:port/{name of file or folder}

    Or


sender:target dir$ tar -cz . | nc -q 10 -l -p 45454
receiver$ nc -w 10 $REMOTE_HOST 45454 | tar -xz

#Pushing  a local GIT repository to remote

#Pulling a GIT remote repository:

#To download an EDX course:

1. Download edx-dl from https://github.com/coursera-dl/edx-dl

2. Now browse to downloaded dir and type:

sudo python setup.py install

3. Now authenticate (your credentials will be protected as per author of edx-dl):

edx-dl -u chap.rishabhk173@gmail.com --list-courses

4. Now use link of one of the course links from output of previous command:

edx-dl -u chap.rishabhk173@gmail.com link

#To rename files in all subdir recursively changing name1 in filename to name2:

find . -type f -exec rename 's/name1/name2/g' *.vtt '{}' \;

#To rename files, appending it's parent name before it's filename:

for file in */*/*; do
        l1="${file%%/*}"
        l2="${file#*/}"
        l2="${l2%%/*}"
        filename="${file##*/}"
        mv "$file" "${l1}_${l2}_${filename}"
done


#To find total playback time of files of a type in a dir:

find . -maxdepth 1 -iname '*.mp4' -exec ffprobe -v quiet -of csv=p=0 -show_entries format=duration {} \; | paste -sd+ -| bc


#Create a custom alias command to open any application via terminal [OSX unix]

open ~/.bash_profile
alias custom_name="open -a /Applications/AppName.app" #append to the file

Comments

Popular posts from this blog

Learn basic regex for Linux in 2 minutes

How to setup a DC hub in your local network