grep regex with wildcard
Hi -
I run a ls and from the output want to retain only part of the string using a wildcard ls output http://localhost/test.com/deploy http://localhost/test1.com/deploy http://localhost/test2.com/deploy I am trying to use grep to output test.com test1.com test2.com Any help appreciated. Thanks in advance |
ummm ... you have files called - http://localhost/test.com/deploy???
Are you retrieving test<blah> because you know the word is test or you need everything between certain slashes?? As you can see I could go on with questions but maybe you could think of adding some more information? |
Code:
$ls | grep test| cut -d "/" -f4 |
It could be any word, test is just an example
http://localhost/test.com/deploy http://localhost/myword.com/deploy http://localhost/anything.com/deploy Thanks |
[SOLVED] grep regex with wildcard
Quote:
Code:
grep -o "/\/.*/deploy"|cut -d "/" -f4 |
So I'll bite .... How did that work? You do not seem to have anything for the grep to read from??
|
Quote:
here is the full command Code:
ls s3://bucketname|grep -o "/\/.*/$UPGRADE"|cut -d "/" -f4 |
All times are GMT -5. The time now is 05:52 PM. |