0

I need to get string between 2nd # to .(dot) using unix command. For ex string is TEST#CV01#170403053938.csv output should be 170403053938

Can some one please advice how to get.

3 Answers 3

1

try:

A="TEST#CV01#170403053938.csv"
B=${A##*#}
echo ${B%%.*}

I am simply using parameter expansion to get the exact required values here.

Sign up to request clarification or add additional context in comments.

Comments

0

Try this -

$ echo "TEST#CV01#170403053938.csv"|egrep -o '[[:digit:]]{10,20}'
170403053938

OR

$ echo "TEST#CV01#170403053938.csv"|awk -F'[#.]' '{print $3}'
170403053938

Comments

0

Could be done with sed (might be overkill), but for the sake of regex!

 echo "TEST#CV01#170403053938.csv"|\
    sed -e 's/\(.*#.*#\)\(.*\)\(\.csv\)/\2/'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.