Forum OpenACS Q&A: Response to Hack wanted: dir name and text in file

Posted by Jerry Asher on
Hi Bob,

If I understand what you are trying to do, it is something that egrep and sed should be able to cons up for you. Something like this example here:

[root@web log]# cd /tmp
[root@web /tmp]# mkdir rocnet
[root@web /tmp]# cd rocnet
[root@web rocnet]# mkdir a
[root@web rocnet]# mkdir b
[root@web rocnet]# mkdir c
[root@web rocnet]# echo "ns_returnredirect "/foo/bar.tcl?id=11730"" > a/afoo
[root@web rocnet]# echo "ns_returnredirect "/foo/bar.tcl?id=11731"" > b/bfoo
[root@web rocnet]# echo "ns_returnredirect "/foo/bar.tcl?id=11732"" > c/cfoo
[root@web rocnet]# egrep -r "[0-9]*" *
a/afoo:ns_returnredirect "/foo/bar.tcl?id=11730"
b/bfoo:ns_returnredirect "/foo/bar.tcl?id=11731"
c/cfoo:ns_returnredirect "/foo/bar.tcl?id=11732"
[root@web rocnet]# egrep -r "[0-9]*" * | sed -e "s//.*=/ /" -e "s/".*$//"
a 11730
b 11731
c 11732
[root@web rocnet]# 
Does that help?