Hey guys,
So this is not really my thing, but I need help with a bash script that will take a whole bunch of text files in a directory, search through them for specific (or exclude) text and put the output to a file.
This is what I have
for f in * ;
do
cat *.txt | grep textiwant1 > /var/output/test.txt ;
cat *.txt | grep textiwant2 >> /var/output/test.txt ;
done
The problem with this, is that it goes through all the files using the first statement, then goes through all the files using the second statement.
I need it to go through the first file with both statements, then go through second file with both statements and so on.
/EDIT/
I see why its going through each file, its because of my cat *.txt statement, how do i tell it to do the first file, then increment.
Im sure i can use a while loop and then increment a variable to show a file incrementation, but i dont know the statements
So this is not really my thing, but I need help with a bash script that will take a whole bunch of text files in a directory, search through them for specific (or exclude) text and put the output to a file.
This is what I have
for f in * ;
do
cat *.txt | grep textiwant1 > /var/output/test.txt ;
cat *.txt | grep textiwant2 >> /var/output/test.txt ;
done
The problem with this, is that it goes through all the files using the first statement, then goes through all the files using the second statement.
I need it to go through the first file with both statements, then go through second file with both statements and so on.
/EDIT/
I see why its going through each file, its because of my cat *.txt statement, how do i tell it to do the first file, then increment.
Im sure i can use a while loop and then increment a variable to show a file incrementation, but i dont know the statements