i have in a linux directory a lot of files, plain text with some directories, and i want to search in all those files and get the exactly the string between “-(” and “)-” like:
bbbfb da bg -(fdsd)- fgfjmui -( juju gfdgf b)- fsdf sdfs dsfdlk,kwwk
xwpv -(64fsdfds)- fsdfsd -(a)- fsdfsd…
and return:
- fdsd
- juju gfdgf b
- 64fsdfds
- a
…
i read for a while, and i found commands like grep, but i tried and i think that command return the exactly string and just one by line:
grep -Rn "-(" *
i tried also sed command like:
sed -e 's/.*-(\([^"]*\))-.*/\1/'
which return all the lines and where is the pattern, only the string inside -( and )-, but is not quite right yet.
i read about awk, but my question is: is possible with grep, sed or awk? there some more things to put on sed command? (i’m kinda new on this)
there is another command to do this? or the other idea i was thinking is make a little c program to read files char by char
this will give you the strings you want each per line
test with your example:
the trick here is “o”: from man page of grep: