how to extract specific name from folder or file name

kohtoo

I'm new to linux command.

Now I would like to extract only date value from listed file name and compare as a date value.

Example:
/underdirectory

20080206
20080207
bk_20080208

I want to listed all above directories and compare date, means this directory is greater or smaller than which is according to specified date. If all of the listed directories will be date, it's ok for condition check.

code

foreach date_directory ( ls )
if ( "$date_directory" >= "$fdate" && "$date_directory" <= "$tdate") then
echo ${target_del}${date_directory} >> ${output}
endif
end

But if include some words such as "bk_20080228" or "bk_20080228_bk" or "20080228_bk" or "20080228_tt", there condition check will be error.

bk_20080208 want to take only 20080208.

please help me. Thanks!

Sergey

use grep regexp grep -Eo '[0-9]{4}[0-9]{2}[0-9]{2}' or grep -Eo '[0-9]+'

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to extract a value from an XML, store the value and use it replace file name and folder name using java?

From Dev

How to extract the file name from a file path?

From Dev

How to extract a string from a file name?

From Dev

How to extract Guid from file name?

From Dev

How to extract name of all files contained in a folder into a .txt file?

From Dev

how to extract just a specific part of a file name in bash

From Dev

VBA - Extract Particular Folder Name from Path

From Dev

print a specific folder name from path on python

From Dev

How do i get images file name from a given folder

From Dev

How to list all file name from a folder using angular js

From Dev

How do i get images file name from a given folder

From Dev

how to open file from a folder with same name in C#

From Dev

How to create a folder from file name and moved it in PHP?

From Dev

How to create a zip file from contents of a folder with certain name pattern?

From Dev

How to extract a file name from its path in vba

From Dev

How to move the file in the folder to outside and change the name to the folder name?

From Dev

Extract a file name from the full file path

From Dev

How to filter full file name or full folder name only from input path using batch?

From Dev

How to get the last folder name and file name from a path using JavaScript?

From Dev

importing from venv folder with same file name

From Dev

importing from venv folder with same file name

From Dev

Get sequential file name from drawable folder

From Dev

Assign the name of the Folder to the name of a file

From Dev

How can i get specific file name from all subdirectotires?

From Dev

How to get a specific file name from a path without the extensions python

From Dev

extract file name from content disposition

From Dev

extract package name from apk file

From Dev

Seletively extract number from file name

From Dev

Extract file name from path in awk program

Related Related

  1. 1

    How to extract a value from an XML, store the value and use it replace file name and folder name using java?

  2. 2

    How to extract the file name from a file path?

  3. 3

    How to extract a string from a file name?

  4. 4

    How to extract Guid from file name?

  5. 5

    How to extract name of all files contained in a folder into a .txt file?

  6. 6

    how to extract just a specific part of a file name in bash

  7. 7

    VBA - Extract Particular Folder Name from Path

  8. 8

    print a specific folder name from path on python

  9. 9

    How do i get images file name from a given folder

  10. 10

    How to list all file name from a folder using angular js

  11. 11

    How do i get images file name from a given folder

  12. 12

    how to open file from a folder with same name in C#

  13. 13

    How to create a folder from file name and moved it in PHP?

  14. 14

    How to create a zip file from contents of a folder with certain name pattern?

  15. 15

    How to extract a file name from its path in vba

  16. 16

    How to move the file in the folder to outside and change the name to the folder name?

  17. 17

    Extract a file name from the full file path

  18. 18

    How to filter full file name or full folder name only from input path using batch?

  19. 19

    How to get the last folder name and file name from a path using JavaScript?

  20. 20

    importing from venv folder with same file name

  21. 21

    importing from venv folder with same file name

  22. 22

    Get sequential file name from drawable folder

  23. 23

    Assign the name of the Folder to the name of a file

  24. 24

    How can i get specific file name from all subdirectotires?

  25. 25

    How to get a specific file name from a path without the extensions python

  26. 26

    extract file name from content disposition

  27. 27

    extract package name from apk file

  28. 28

    Seletively extract number from file name

  29. 29

    Extract file name from path in awk program

HotTag

Archive