awk - Formating the output in shell -


After executing some commands in the shell, I get the following output,

  File1.txt @@ / main / v1 / v2 / v3 / v4 / v5 / v6 / v7 / v8 / v9 / v10 / 5 file2.txt @@ / main / v4 / v5 / v6 / v7 / v8 / V9 / V10 / 4 file3.txt @@ / main / v9 / v10 / 8   

Please tell me which command I can apply to get the final output below , Just file name and last 5 characters in each row -

  file1.txt v10 / 5 file2.txt v10 / 4 file3.txt v10 / 8    

Use awk

  awk -F "[@ /]" '{print $ 1, $ (NF-1) "/" $ NF}' file file1 .txt v10 / 5 file2.txt v10 / 4 file3.txt v10 / 8   

@ and / , print the first field Please, print the other previous fields and the last fields.

If the tab is required:

  awk -f "[@ /]" '{print $ 1} \ t "$ (NF-1)" / " $ NF} 'file file1.txt v10 / 5 file2.txt v10 / 4 file3.txt v10 / 8    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -