Re: Isolate lines in a text file and perform replacements
- From: "Mumia W." <paduille.4060.mumia.w+nospam@xxxxxxxxxxxxx>
- Date: Fri, 30 Mar 2007 20:53:45 GMT
On 03/30/2007 01:16 PM, Robert Neville wrote:
[...] script below performs this task (yet has not been thorough tested). It has a major shortcoming that the Perl line works on the entire file when it should only replace the lines with mp3 pointers. Here's the call for assistance since I am having code block. Maybe, someone could help me with different logic or a traditional grep solution.
find ./ -regex ".*\(m3u\|sfv\|xml\)$" -type f -print | while read FILE
do while read -r REGEX REPLACE line
do
CODE="$CODE; s/$REGEX/$REPLACE/g"
done < "$PRESET"
echo "$CODE"
echo "perl -pi.bak -e "s/$REGEX/$REPLACE/g" $FILE"
Is this what you're looking for?
echo "perl -pi.bak -e \"s/$REGEX/$REPLACE/g if /\.mp3\b/\" $FILE"
#PRESET may contain over twenty five regex patterns
done
btw I am doing this script in Bash, because Perl is foreign territory.
.
- References:
- Isolate lines in a text file and perform replacements
- From: Robert Neville
- Isolate lines in a text file and perform replacements
- Prev by Date: Re: regular expression help
- Next by Date: Re: Problem installing Apache::Test
- Previous by thread: Re: Isolate lines in a text file and perform replacements
- Next by thread: regular expression help
- Index(es):
Relevant Pages
|
|