How can i use cut and sed in awk?

Nervous :

First of all I'm new here and i want to know how can i use cut and sed in awk of any method to edit my test data for keep that data to array

This is my sample data:

isdat    pts/0        10.80.24.3       Fri Sep 20 10:20:30 2019 - Fri Sep 20 11:55:51 2019  (01:35)

normally i can choose usage_time by awk '{print $15}' it's gonna be like this
output : (01:35)

and i will cut by cut -d ':' -f1 | sed -e 's/(/ /' for hour and this for minute cut -d ':' -f2 | sed -e 's/)/ /'

But cut and sed can't use in awk how can i solve this problem

James Brown :

You don't use them. Awk is perfectly capable of handling that on its own:

$ awk '
$2~/^pts/ {                     # the grep part
    split($15,a,/:/)            # split $15 by :
    for(i in a)                 # process all parts (2)
        gsub(/[()]/,"",a[i])    # remove parentheses
    print a[1],a[2]             # output both parts
}' file

Output:

01 35

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=27297&siteId=1