0

I've a file name called xx-xx-1.2.3.4-xx.txt and i wanted the output should be 1.2.3.4-xx (i.e. from second - to till .). how can we do it in linux command line?

Thanks jb

  • Please clarify you question. It is not clear enough – Imran Jul 08 '15 at 17:43
  • I'm using bash shell. Sorry if its not clear. my name file format is "xx-xx-1.2.3.4-xx.txt" and i wanted to print "1.2.3.4-xx" from the name. can you help to get this done through linux command line? – user5095145 Jul 08 '15 at 17:45
  • please update your question with a example. for instance, if I was asking the question I would say my file name is Bigdog-jake-file.txt and I want to crop off the first section so that the file is jake-file.txt. I want to do this via the command line. just using x's is confusing. – Jess Patton Jul 08 '15 at 17:53
  • the sample file name is: "abc-def-1.2.3.4-ghi.txt", and the expected is "1.2.3.4-ghi" – user5095145 Jul 08 '15 at 17:57
  • It's still not clear. You are writing a shell script? If so, how does your script know what file name to parse? Are you passing the filename as a command line parameter to the script? Is the filename stored in a variable? – Lithis Jul 08 '15 at 18:02
  • possible duplicate of [bash - remove a fixed prefix/suffix from a string](http://stackoverflow.com/questions/16623835/bash-remove-a-fixed-prefix-suffix-from-a-string) – Lithis Jul 08 '15 at 18:11
  • Using the answer from [bash - remove a fixed prefix/suffix from a string](http://stackoverflow.com/questions/16623835/bash-remove-a-fixed-prefix-suffix-from-a-string), your prefix would be `*-*-` and your suffix would be `.*`. – Lithis Jul 08 '15 at 18:13

0 Answers0