bash - Keep the delimiter in the output of cut -


I have a script which, to remove some code from search, cut Uses Path. Something looks like this:

  PLACE = $ (grep foo flatfile.txt | cut -d '/' -f 1-6)   

Output this Looks like:

  machine1: / path / to / where / foo / is machine2: / another / path / to / find / foo   

I It should look like this:

  machine1: / path / to / where / foo / is / machine2: / another / path / to / find / foo /   

This console should be printed with the echo "$ PLACE" at the end of the script or some such output will always have at least 2 rows, but usually more.

I tried, which I thought I could think with Echo, but it does not show any output or gives output:

  grep : '/' Is a directory   

I am running bash 3.00 on Solaris, if he does any help, I would really like KIS. Despite the deduction of something else at the end of the command, and not with the seed or the unit being with the monkey But, if this is the only way, then be it.

Try this: PLACE = $ (grep foo flatfile .txt | cut -d '/' -f 1-6 | xargs -i "%" echo% /)

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 -