KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
i am trying to extract a substring with awk from a command answer in bash example output line: abc_def_ghi jkl_lmn_opq getting the second part is easy by echo abc_def_ghi jkl_lmn_opq | awk '{print $2}' but i only need the last part substring "opq" and didn't find a way to let awk run twice over the string, when i pass the result from above to a var and use this var for second awk i get an error because the string is a path and therefore a Directory. too i didn't get sed to work with the same error when used on a stored var with the string and i did not manage to pass first substring to second awk or sed. weird? this would do the Job if not first awk would print out instead of passing to second awk echo abc_def_ghi jkl_lmn_opq | awk '{print $2}' | awk -F"_" '{print $3}' works neither echo abc_def_ghi jkl_lmn_opq | awk '{$2}' | awk -F"_" '{print $3}' how can i pass it right to secondly strip?
Tags (comma-separated)
Save Edits
Cancel