I had 5000 text files in a directory, each text file name starts with a prefix OG00* (ex - OG0017774.log)
The .log files which contains asterisk (*) inside the file, need to be copied into a new directory.
The content of the file -
cat OG0017774.log
M0~b904dbe442e0eb658d229076cacb9ef6 M1~9edeedcb1f4f315c4689bacd8075222f 0.000035**
M0~b904dbe442e0eb658d229076cacb9ef6 M2~aeba83b564ee32e0ef1a8321c8d930f4 0.000671**
M0~b904dbe442e0eb658d229076cacb9ef6 M3~006a376da2fba16185ce424bf4cba983 0.000055**
M0~b904dbe442e0eb658d229076cacb9ef6 M4~e564dbfbbbe8d1f7d9d8c8e4da202943 0.000015**
M0~b904dbe442e0eb658d229076cacb9ef6 M5~2abe603e8fee2fcb08b7fb818957e0aa 0.000006**
Suggestions appreciated.
I tried this code, it copies all the files in the current directory to a new directory.
I want to copy those files which had * inside the each text file.
#!/bin/bash
KEYWORD_PATTERN='*'
find . -type f |
while read FNAME
do
if grep -Ew -q "$KEYWORD_PATTERN" $FNAME
then
KEYWORD=$(grep -Ew -o "$KEYWORD_PATTERN" $FNAME)
cp -r $FNAME keywords/$KEYWORD
fi
done