linux - how to extract part of a string in shell script? -


i use last | grep pts/ check login raspberry pi:

samuelli pts/2        localhost        fri apr 24 19:51   still logged in    pi       pts/1        localhost        fri apr 24 19:50 - 19:53  (00:03)     liuly    pts/1        localhost        fri apr 24 19:50 - 19:50  (00:00)  

now want extract user name pi , login time fri apr 24 19:51 , output username , time file. how write script ? using cut ?

using awk print out username time , >> can redirect text file:

last | grep pts/ | awk '{print $1 " "$4 " "$5 " "$6 " "$7}' >> sampletest.txt


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -