SED question

I have the following string:
"File Reader"

I also have a list of directories:
"File Reader (#53)"
"CSV Writer (#47)"
"Scorer (#22)"

I want to search the name of each directory until I find "File Reader". Then, I want the corresponding number to be returned.

For example, if I am searching for File Reader, the desired output I am looking for is 53.

Thanks

---------- Post updated at 06:27 PM ---------- Previous update was at 05:10 PM ----------

Can SED be used to accomplish this?

Can you be please more elaborate on this ??

Do you want to search for a directory and want to print the number of files in that ??

                                \(OR\)

All the directory names and number of files in that are mentioned in a file .And you want to search that file for a given directory name ??

Try this:

sed -e '/File Reader/!d' -e 's/.*#\(.*\))"/\1/g'  fileread.txt

Sorry for not making myself clear:
The actual names of the directories are:
"File Reader (#53)"
"CSV Writer (#47)"
"Scorer (#22)"

but to just make it simple we can rename them to:
"dir1 (#29)"
"dir2 (#45)"
"dir3 (#23)"

I have gathered all of the directory names using the following code:

dirs=`ls -d  *(#*`
echo $dirs

output:
"dir1 (#29)"
"dir2 (#45)"
"dir3 (#23)"

Now I would like use SED to return the number portion of the desired directory name. For example, I would like to be able to input the string "dir1". Using the list of directories that I have already generated and stored into variable $dirs I want the output to be 29. Preferably if this value could be stored in a variable also would be great. Alternatively, if I was looking for "dir2" from the list of dirs, the desired output would be 45. Likewise for "dir3" where the desired output would be 23.

The number is part of the directory's name. All I am trying to do is cut the desired directory name and only return the number portion.

this did not work and returned the following message:
sed: can't read fileread.txt: No such file or directory

I am not sure why it is looking for an input file. No input file is needed.

ls -d  *(#* | sed 's/.*#\([0-9]*\).*/\1/'

should do the trick

$ ls -1
CSV Writer (#47)
File Reader (#53)
Scorer (#22)
ans
 
$ cat ans
function getnum
{
    echo "$1 (#"* | sed 's/.*#\([0-9]*\).*/\1/'
}
getnum Scorer
getnum "Dummy"
getnum "CSV Writer"
 
$ ./ans
22
 
47

One with awk,

 
ls -d  *(#* | awk -F"[(#)]" '{ print $3 }'

Thanks everybody! It works perfectly.:smiley: