Needed to do this and after a bit of looking around (Bash scripting) came up with this:
[ -f $FILE_LIST_SOURCE ] && LIST_OF_FILES=$(cat $FILE_LIST_SOURCE)
#echo -e "\\nLIST_OF_FILES:\\n$LIST_OF_FILES"
echo "List of files:"
for i in $LIST_OF_FILES; do
Wanted to find all files which contained a specific string and then extract a part of the line we were interested in.
First the GREP:
grep -R --include=*.vm * > results.txt
then run this python script:
for line in open('editablecomponents.txt'):
match = re.search(r'#editableComponent\("(.*?)"', line)
print match.group(1) + "Display.vm"
Been doing quite a bit of manipulating LaTeX files on the command line recently, and have a very sweet little command for searching for text in multiple files:
grep -r Hoffman */*.tex | less +/Hoffman
Where “Hoffman” is the search term which can of course be any regular expression.
The “less” command has a very convenient argument “+” which allows you to pass a search term in and will automatically highlight it for you.
The -r in grep recurses directories and */*.tex looks for all tex files. the | pipes the result to less.