SED examples

Posted: April 15, 2016 in Linux
Tags:

sed -i '/^#/d' vendor/broadcom/hammerhead/device-partial.mk #remove all lines beginning with #

sed -i '1,2d' vendor/broadcom/hammerhead/device-partial.mk #delete 1st 2 lines

sed -i 's_:broadcom \\_ _g' vendor/broadcom/hammerhead/device-partial.mk #replace :broadcom \ with a space

sed -i 's_:system_ system_g' vendor/broadcom/hammerhead/device-partial.mk #replace :system with system

sed -i 's_ vendor/_install -D -m 644 vendor/_g' vendor/broadcom/hammerhead/device-partial.mk #replace vendor/ with install -D -m 644 vendor/

sed '1 i\#!/bin/bash' vendor/broadcom/hammerhead/device-partial.mk #add #!/bin/bash to 1st line

Android phones may already have a terminal emulator app installed by default (otherwise install a terminal emulator app from the Google Play store) then do the following;

tar czvf - inputfilename |split -b 5M - outputfilename.tar.gz.

Resulting filenames will be outputfilename.tar.gz.aa, outputfilename.tar.gz.ab, outputfilename.tar.gz.ac etc.

inputfilename can be a file or folder, 5M in above example splits files into 5MB sizes.

To extract/recombine;

cat outputfilename* |tar xzvf -

Credits to StackExchange

Linux curl command usage example

Posted: September 2, 2015 in Linux
Tags:

Enter the following into any Terminal window to begin/continue downloading a file from most webservers.

curl -C - -O http://filename

Credits to TheGeekStuff

Try the following if you just flashed a brand new custom ROM and experienced subject error when trying to install a side loaded .apk.

Credits to Jani-

Enter the following into any Terminal Emulator app from the Google Play Store.

strings /system/lib/libeffects.so|grep -i gcc

Credits to BelzIgoh

sudo apt-get install openjdk-7-jdk git gnupg ccache lzop libglapi-mesa-lts-utopic libgl1-mesa-dri-lts-utopic flex bison gperf build-essential zip curl zlib1g-dev libc6-dev lib32bz2-1.0 lib32ncurses5-dev x11proto-core-dev libx11-dev libreadline6-dev lib32z1-dev libgl1-mesa-glx-lts-utopic libgl1-mesa-dev-lts-utopic g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc libreadline6-dev lib32readline-gplv2-dev libncurses5-dev bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev lib32bz2-dev squashfs-tools pngcrush schedtool dpkg-dev python-networkx zip

As of 9 March 2016, CM13 seems to also require installation of maven.

Dirty Unicorns ROM also requires liblz4-tool in addition to above.



Below example rotates video clockwise – use –rotate=”7″ to rotate counterclockwise.

handbrakeCLI -i inputfile.mp4 -f mp4 -e x264 -b 800 -w 568 -a 1 -E faac -B 96 -x level=4.0:ref=5:weightp=1:subq=2:mixed-refs=0:trellis=0:vbv-bufsize=25000:vbv-maxrate=20000:rc-lookahead=10 -v --rotate="4" --start-at duration:150 --stop-at duration:300 -o outputfile.mp4



To convert say all *.mp4 files in current directory to an already existing “out” directory (assuming in a bash shell);

for i in *.mp4;do handbrakeCLI -i $i -f mp4 -e x264 -b 800 -w 568 -a 1 -E faac -B 96 -x level=4.0:ref=5:weightp=1:subq=2:mixed-refs=0:trellis=0:vbv-bufsize=25000:vbv-maxrate=20000:rc-lookahead=10 -v --rotate="4" --start-at duration:150 --stop-at duration:300 -o out/$i;done