bash grep file directories

stevo

I want to grep 'run' numbers in some files e.g.

files/run3/testlog
files/run14/testlog
files/run28/testlog

I have the following code:

for f in $(find . -name testlog)
do
     echo $(pwd) | egrep -o run[0-9]{*}
done

I want my code to output:

run3
run14
run28

However I am not getting any output.

Jonas Raedle

I think the problem are the curly brackets around *, just try egrep -o run[0-9]*.

If you don't want to match "run", try egrep -o run[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

Bash grep avoid checking directories

From Dev

grep command for a text file in multiple directories

From Dev

Can I ignore __pycache__ directories in bash-completion and grep?

From Dev

Bash, grep sentence from file

From Dev

List only file names in directories and subdirectories in bash

From Dev

Bash: Get file name under different directories

From Dev

File Handling and making directories to match in bash

From Dev

"bash: ... No such file or directory" returned for all files and directories!

From Dev

grep exact pattern from a file in bash

From Dev

Bash: grep multiple items in a file loop

From Dev

Bash: grep multiple items in a file loop

From Dev

Bash: grep selected text from a file

From Dev

How to grep a section of a file in bash shell

From Dev

Bash : how to grep string from file

From Dev

Sort output of grep by file size? (bash)

From Dev

grep: How to exclude directories?

From Dev

Windows 10 and WSL - Directories not appearing in Bash when created in File Explorer

From Dev

Bash command to create a new file and its parent directories if necessary

From Dev

find command in bash script resulting in "No such file or directory" error only for directories?

From Dev

Bash get specific file with name in all directories and run script

From Dev

bash to create sub directories in folder from specific file extension

From Dev

bash list all directories, subdirectories, folders, subfolders in then output to a separate file

From Dev

Easy way to grep for text in one file only in directories containing a second file

From Dev

Linking directories inside directories in Bash

From Dev

recursive grep: exclude specific directories

From Dev

grep or find a pattern in all directories

From Dev

ps aux | grep searches in .bash_history file

From Dev

Bash Script: printing grep'd lines from file

From Dev

Bash Perform multiple grep searches using patterns stored in a file

Related Related

  1. 1

    Bash grep avoid checking directories

  2. 2

    grep command for a text file in multiple directories

  3. 3

    Can I ignore __pycache__ directories in bash-completion and grep?

  4. 4

    Bash, grep sentence from file

  5. 5

    List only file names in directories and subdirectories in bash

  6. 6

    Bash: Get file name under different directories

  7. 7

    File Handling and making directories to match in bash

  8. 8

    "bash: ... No such file or directory" returned for all files and directories!

  9. 9

    grep exact pattern from a file in bash

  10. 10

    Bash: grep multiple items in a file loop

  11. 11

    Bash: grep multiple items in a file loop

  12. 12

    Bash: grep selected text from a file

  13. 13

    How to grep a section of a file in bash shell

  14. 14

    Bash : how to grep string from file

  15. 15

    Sort output of grep by file size? (bash)

  16. 16

    grep: How to exclude directories?

  17. 17

    Windows 10 and WSL - Directories not appearing in Bash when created in File Explorer

  18. 18

    Bash command to create a new file and its parent directories if necessary

  19. 19

    find command in bash script resulting in "No such file or directory" error only for directories?

  20. 20

    Bash get specific file with name in all directories and run script

  21. 21

    bash to create sub directories in folder from specific file extension

  22. 22

    bash list all directories, subdirectories, folders, subfolders in then output to a separate file

  23. 23

    Easy way to grep for text in one file only in directories containing a second file

  24. 24

    Linking directories inside directories in Bash

  25. 25

    recursive grep: exclude specific directories

  26. 26

    grep or find a pattern in all directories

  27. 27

    ps aux | grep searches in .bash_history file

  28. 28

    Bash Script: printing grep'd lines from file

  29. 29

    Bash Perform multiple grep searches using patterns stored in a file

HotTag

Archive