Search code examples
unixclearcase

how to use awk to get the location of current view in clearcase


I want to use awk to get the second directory pattern I am able to do the same using cut -d command and need to use reverse as there is a problem that space between the two dir does not remains the same.

Here is the string I just want the third pattern one marked in bold. I am able to achieve this with cut -d and rev but want to achieve it with awk.

* example_view    /nas/viewstore/admin/example_view.vws

please note the space between the two string varies so we cannot use a fixed value.

I used the following command to do so please take in to consideration of the * which comes when the view is set somewhere.

cleartool lsview -cview |rev | cut -d ' ' -f 1 | rev|xargs 

Solution

  • Use awk as shown below:

    cleartool lsview -cview | awk '{print $NF}'
    

    $NF refers to the last field and, by default, awk uses whitespace as a delimiter.