Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash/ Take substring from a string [duplicate]

Tags:

bash

sh

I run the next:

 find . -type f -printf '%T@ %p\n' | sort -n | tail -1

this return me the next:

1376221215.000000000 ./Rev.12345/run.exe

I want to get only the 12345 number. Which command I should use (I try to use cut command, without success)?

like image 441
user2490373 Avatar asked Oct 17 '25 11:10

user2490373


2 Answers

You can pipe the output to sed:

... | sed 's/.*Rev\.\([0-9]*\).*/\1/'
like image 55
hek2mgl Avatar answered Oct 20 '25 00:10

hek2mgl


You can pipe the output with:

awk -F '[./]+' '{print $4}'
like image 25
anubhava Avatar answered Oct 20 '25 02:10

anubhava



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!