Quote:
i want to sed the whole line to be sorted time alone in new line and date alone in another new line.
which means the new result should be like this:-
Thu Aug 14
13:07:26
|
No need to use sed, just use:
Code:
date +"%a %b %d"
date +"%T"
%a, %b and others known as FORMAT controls. They control the output of date. To see all interpreted sequences, read man page:
Quote:
i got this command which shows my ip address
who am i | sed 's/[^(]*(\([^)]*\))/\1/'
the problem thats sed command shows also character between the numbers which means it does not show the ip ,, but it shows the whole hostname.
|
To see your own IP address use ifconfig command:
Code:
/sbin/ifconfig
/sbin/ifconfig eth0
/sbin/ifconfig eth0 | grep inet
Now same stuff using awk:
Code:
ifconfig eth0| awk 'NR==2 {print $2}' | awk -F: '{print $2}'
See
Shell Script To Read IP Address ( Find Ip Address Script )
Quote:
for example if i type the command
who am i | sed 's/[^(]*(\([^)]*\))/\1/'
the result will be
sde-84-109-50-43.red.sde.net
now i need the numbers only
which means the new result should be
84.109.50.43 (with dot
|
Try to convert hostname to IP using host command
Code:
host $(who am i | sed 's/[^(]*(\([^)]*\))/\1/') | awk '{ print $4}'