[root@test]# cat input a,b,c,d [root@test]# cat input | sed 's/','/\n/g' a b c d [root@test]# cat input | awk '$1=$1' RS=, OFS="\n" a b c d [root@test]# cat input | tr -s ',' '\n' a b c d
Enjoy 🙂
[root@test]# cat input a,b,c,d [root@test]# cat input | sed 's/','/\n/g' a b c d [root@test]# cat input | awk '$1=$1' RS=, OFS="\n" a b c d [root@test]# cat input | tr -s ',' '\n' a b c d
Enjoy 🙂
Sometime back I had explained how to find the difference and common lines in two files, Using that giving you 2 simple (very simple) scripts
1. Find out the missing lines between two files
cat diff.sh #!/bin/bash if [ $# -eq 0 ];then echo "No arguemnts given; Usage : ./diff file2 file1" exit 1 fi echo "Lines exist in $2 and not in $1 are :" grep -Fxv -f $1 $2
2. Find out the common lines between two files
cat common.sh #!/bin/bash if [ $# -eq 0 ];then echo "No arguments given; Usage : ./common file1 file2" exit 1 fi echo "Common files in $1 and $2 are :" awk 'NR==FNR{a[$1]++;next} a[$1] ' $1 $2
Enjoy 🙂
Everyone know how to copy and paste characters in putty terminal using mouse (in case you don’t know, selecting the characters using mouse automatically copies and right click paste it) but less people know that it is possible with keyboard as well. You can use the below command to paste the characters into putty terminal
SHIFT + INS
Enjoy 🙂
You can use the awk command to compare two files and show the common ones. Compared to the Linux command “comm”, advantages of using “awk” is it will give output though the files are not sorted.
Syntax :
awk 'NR==FNR{a[$1]++;next} a[$1] ' file1 file2
Eg :
[root@test]# cat A apple orange mango grape [root@test]# cat B mango banana grape [root@test]# awk 'NR==FNR{a[$1]++;next} a[$1] ' A B mango grape
You might have come across this headline, especially if you working with Oracle Virtual box machines, machines those are cloned from previous setups etc.
To resolve the issue, just remove the file /etc/udev/rules.d/70-persistent-net.rules and reboot the machine. This file contains the MAC address details associated with the machine. If you don’t want to reboot the machine, run the below command :
udevadm trigger --subsystem-match=net
This command will trigger the rules again.
Enjoy 🙂
Go to the link : http://www.oracle.com/technetwork/java/javase/downloads/
Accept the license agreement and Download the tar.gz file (eg: jdk -8u65-linux-i586.tar.gz)
Extract the file using the command tar -xzvf jdk-8u65-linux-i586.tar.gz
Copy the extracted directory (In my case jdk1.8.0_65) to the required location say /scratch
alternatives –install /usr/bin/java java /scratch/jdk1.8.0_65/bin/java 20000
alternatives –config java
You can see the list of available java versions and select our installed one by typing the number corresponding to that one.
By default /etc/rc.local
and /etc/rc.d/rc.local
are no longer executable in CentOS7 with the new systemd-changes. Follow the below steps to make the script /root/g.sh run at boot time:
1. chmod +x /etc/rc.d/rc.local 2. chmod +x /root/g.sh 2. Mention your script at the bottom of the file /etc/rc.local (/etc/rc.local is a symlink to /etc/rc.d/rc.local)as below : sh /root/g.sh
Restart and check 🙂
1. Install the package : facter
In centOS : yum install facter
In ubuntu : apt-get install facter
2. Run the command :
facter virtual
3. Check the output.
for example :
[root@test1 ~]# facter virtual vmware
root@test2:~# facter virtual physical
Thanks 🙂
To change the color of the terminal :
tput setaf number
Use the below numbers for the corresponding color.
Black : 0
Red : 1
Green : 2
Yellow : 3
blue : 4
Magenta : 5
Cyan : 6
White : 7
Eg : For Green(my fav :)),
tput setaf 2
Enjoy 🙂
1. First create a p12 file and import both the certificate and key into it using openssl.
openssl pkcs12 -export -name theg -in /etc/ssl/certs/theg.crt -inkey /etc/ssl/private/theg.key -out theg.p12
2.Convert the p12 format into jks format using keytool :
keytool -importkeystore -destkeystore theg.jks -srckeystore theg.p12 -srcstoretype pkcs12 -alias theg
Note : Here I used the name theg for my certificates and alias, change it accordingly.