I have below set of data in unix txt file:
/this/is/a/directory_name/which/i/want:listen= tcp://someurl
/this/is/a/another_directory_name/which/i/want:listen= tcp://someotherurl
the output which basically intended is:
directory_name <whitespace> tcp://someurl
another_directory_name <whitespace> tcp://someotherurl
Below is the command that I am trying but only getting either the url or either the directoryname
cat the_file.txt|awk -F '/' '{print $5}'
cat the_file.txt|awk -F '=' '{print $2}'
can there be a way to achive both of the above command simultaneously and get the output in the same line ? Much appriciated
Just keep the first command and do a tweak for the second one: split the full text based on = and print the second resulting field:
$ awk -F'/' '{split($0, a,"="); print $5, a[2]}' file
directory_name tcp://someurl
another_directory_name tcp://someotherurl
Or the last one if there are many =s:
$ awk -F'/' '{n=split($0, a,"="); print $5, a[n]}' file
directory_name tcp://someurl
another_directory_name tcp://someotherurl
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With