paste <(echo "$VAR1") <(echo "$VAR2") --delimiters ' '
nvidia-smi -pm 0 # Disable
nvidia-smi -pm 1 # Enable
seq 6 | paste -sd" "
cat textfile | awk '/PATTERN_START/{flag=1; next} /PATTERN_END/{flag=0} flag'
# Include the pattern matched too
cat textfile | sed -n '/PATTERN_START/,/PATTERN_END/p'
cat textfile | awk '/PATTERN_START/,/PATTERN_END/'
rpm -qa kernel
dpkg --list | grep linux-image
http://ubuntuhandbook.org/index.php/2014/11/connect-cisco-anyconnect-vpn-ubuntu/
# Install OpenConnect:
sudo apt-get install openconnect
# Connect to VPN, run:
sudo openconnect yourvpn.example.com
# Enable
for x in {2..4} ; do echo 1 > /sys/devices/system/cpu/cpu${x}/online ; done
# Disable
for x in {2..4} ; do echo 0 > /sys/devices/system/cpu/cpu${x}/online ; done
Use root or sudo to take cpu profile
# Start profile
perf record -a <command>
perf record -a -p <pid>
# profile result
perf report -i perf.data
# Create a softlink python of python3
ln -s python3 python -f
# -f option to force
for d in train/* ; do find $d -name "*.jpg" | xargs -I {} file {} >> train_info.txt & done
# Note: there is no ';' before done
find train -name "*.jpg" | xargs -I {} file {} >> train_info.txt
for d in train/* ; do find $d -name "*.jpg" | xargs -I {} file {} >> train_info.txt & done
lines=$(data_filter_to_a_single_column) ; avg=0; n=0; for l in $(echo "$lines") ; do avg=$(echo "scale=12; ($avg * $n + $l)/($n + 1)" | bc) ; n=$(expr $n + 1) ; done; echo $avg
OpenJDK 8 is not available on Trusty. To install Oracle JDK 8:
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
To install OpenJDK 8:
sudo apt-get install openjdk-8-jdk
sed -i ':a;N;$!ba;s/Hello\/World\/hello.c:11[^\n]*\n//g' logfile # This remove new line too
sed -i 's,text,'$text',g' file
# git clone a particular branch
git clone -b branch-name https://github.com/abc/xyz.git
git clone https://github.com/abc/xyz.git
cd xyz
git checkout branch-name/b46130b922d47ff20ac40ebbdef01f7771e1d0bc
# code change
git add inception/inception/inception_train.py
git commit
# Apply patch
git apply file.patch
# cherry-pick
git remote add ibmsoe https://github.com/abc/xyz
git fetch pqr
git cherry-pick b46130b922d47ff20ac40ebbdef01f7771e1d0bc
matched_text=$(echo $single_line_text | sed 's/.*xyz=\([^ ][^ ]*\).*/\1/')
# Note: Need to change the pattern accordingly
ext=$(date +%d%b%Y_%H%M%S)
if echo $line | grep "xyz" > /dev/null ; then
echo "xyz present"
elif echo $line | grep "XYZ" > /dev/null ; then
echo "XYZ present"
else
echo "not present"
fi
declare -A arr
arr[$key]=$val
val=${arr[$key]}
tar -cvf filename.tar directory # Create a .tar file
tar -cvzf filename.tar.gz directory # Create a .tar.gz file
tar -cvjSf filename.tar.bz2 directory # Create a .tar.bz2 file
tar -xvf filename.tar # Untar a .tar file
tar -xvzf filename.tar.gz # Uncompress a .tar.gz file
tar -xvjf filename.tar.bz2 # Uncompress a .tar.bz2 file
tar -xf filename.tar.xz # Uncompress a .tar.xz file
# Note: Use -C option to extract files to a specific directory
$ command >> filename 2>&1
grep -rnw '/path/to/somewhere/' -e "pattern"
If you are not root user use sudo for the following commands.
A. Use the adduser command to add a new user to your system.
# adduser <username>
B. Use the usermod command to add the user to the sudo group.
# usermod -aG sudo <username>
--- OR ---
B. Grant Root Privileges to the User
# visudo
Find the following code:
# User privilege specification
root ALL=(ALL:ALL) ALL
In this case, we’re granting root privileges to the user username. Add the following below that code:
username ALL=(ALL:ALL) ALL
Then exit and save the file with the key commands Ctrl-x, Y, enter.
sudo apt-get --only-upgrade install <packagename>
sudo dpkg -x package.deb /tmp/out
sshpass -p $PASS ssh -o StrictHostKeyChecking=no $USER@$HOST "mkdir -p ~/tmp_$dir"
sshpass -p $PASS scp -r $dir/* $USER@$HOST:~/tmp_$dir
sshpass -p $PASS ssh -f $USER@$HOST "cd ~/tmp_$dir ; screen -dm -S label_$(date +%d%b%Y_%H%M%S) ./startBatch.sh"
# sshpass -p $PASS ssh -f $USER@$HOST "cd ~/tmp_$dir ; nohup ./startBatch.sh &"
find <DIR> -type f -print0 | xargs -0 sed -i 's/TEXT1/TEXT2/g'