How to extract one row if it contains specific characters such as "|" and put it on the first row?
For example:
varl="This is the first row (I might be specific)
...
This is the ith row (I might be specific)
...
this row contains I|am|sepcific|
...
This is the last row (I might be specific)
"
The output should look like:
varl="this row contains I|am|sepcific|
This is the first row (I might be specific)
...
This is the ith row (I might be specific)
...
...
This is the last row (I might be specific)
"
The specific row could be present in any row.
What I did is a bit messy and didn't get the right result:
new_varl=`echo "$varl" | grep '|'`\n`echo "$varl" | grep -v '|' `
But the result is :
new_varl="this row contains I|am|sepcific|\nThis is the first row (I might be specific)
...
This is the ith row (I might be specific)
...
...
This is the last row (I might be specific)"
\n
didn't work as a carriage return
|
character? – doneal24 Oct 26 '22 at 19:59