Extract just file path from string

user3746428

I have a file that contains strings in this format:

MD5 (TestImages/IMG_0627.JPG) = 6ed611b3e777c5f7b729fa2f2412d656

I am trying to figure out a way to extract the file path, so that I would get a string like this:

TestImages/IMG_0627.JPG

For a different part of my script, I am using this code to remove everything before and after the brackets, and I could of course do something similar, however I'm sure there is a better way?

shortFile=${line#*MD5 }
shortFile=${shortFile%%)*}

Anyone have any suggestions?

miken32

You could use sed but that has the overhead of starting a new process.

echo $line | sed -r 's/MD5 \((.*)\).*/\1/'

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Extract string from a path

From Dev

Need to extract a substring from a file path string including the delimiter

From Dev

Need to extract a substring from a file path string including the delimiter

From Dev

Extract filename from path string

From Dev

PHP extract just a specific number from a string

From Dev

extract path to directory from path to file

From Dev

Extract a file name from the full file path

From Dev

How to extract the file name from a file path?

From Java

Extract part of a string from a path - Java Regex

From Dev

Makefile: extract pattern from a full path string

From Dev

How to Extract Items From an LDAP Path String

From Dev

Extract string from path/dir using Make

From Dev

Extract date from file path in java

From Dev

Extract file name from path in awk program

From Dev

Extract file extension from URL path in R

From Dev

Extract string under a string from a file in linux

From Java

Extract file name from path, no matter what the os/path format

From Java

How can I extract the folder path from file path in Python?

From Dev

Extract absolute file path from a QRessource loaded file

From Dev

Extract number from string in batch file

From Dev

Extract string from each line of a file

From Dev

Extract a string from all lines in a file

From Dev

How to extract a string from a file name?

From Dev

Bash extract string from file to use as variable

From Dev

How to extract particular string from a file (linux)

From Dev

Extract a Path from a server log String using regular expressions in Scala

From Dev

Extract path from a entire string in bash shell script

From Dev

Extract file path from android Intent.ACTION_SEND

From Dev

How to extract a file name from its path in vba

Related Related

  1. 1

    Extract string from a path

  2. 2

    Need to extract a substring from a file path string including the delimiter

  3. 3

    Need to extract a substring from a file path string including the delimiter

  4. 4

    Extract filename from path string

  5. 5

    PHP extract just a specific number from a string

  6. 6

    extract path to directory from path to file

  7. 7

    Extract a file name from the full file path

  8. 8

    How to extract the file name from a file path?

  9. 9

    Extract part of a string from a path - Java Regex

  10. 10

    Makefile: extract pattern from a full path string

  11. 11

    How to Extract Items From an LDAP Path String

  12. 12

    Extract string from path/dir using Make

  13. 13

    Extract date from file path in java

  14. 14

    Extract file name from path in awk program

  15. 15

    Extract file extension from URL path in R

  16. 16

    Extract string under a string from a file in linux

  17. 17

    Extract file name from path, no matter what the os/path format

  18. 18

    How can I extract the folder path from file path in Python?

  19. 19

    Extract absolute file path from a QRessource loaded file

  20. 20

    Extract number from string in batch file

  21. 21

    Extract string from each line of a file

  22. 22

    Extract a string from all lines in a file

  23. 23

    How to extract a string from a file name?

  24. 24

    Bash extract string from file to use as variable

  25. 25

    How to extract particular string from a file (linux)

  26. 26

    Extract a Path from a server log String using regular expressions in Scala

  27. 27

    Extract path from a entire string in bash shell script

  28. 28

    Extract file path from android Intent.ACTION_SEND

  29. 29

    How to extract a file name from its path in vba

HotTag

Archive