I'm running the following command:
cat /tmp/myfile.log | sed -n -e 's/^.*Expire: //p'
Which returns the following string
04-nov-2018
I then want to run that string through the following command:
date -d '04-nov-2018' + "%s"
that will return the unixtime:
1541304000
How do I run that in a single command line?
Best Answer
You can run a command within a
$( )
, so that you can directly say:In your case:
Note also I am saying
sed '...' file
instead ofcat file | sed '...'
, sincesed
can directly read from the file.