i am an enthusiast of computers but never studied programming.
i am trying to learn Perl, because i found it interesting since i learned to use a little bit of regular expressions with Perl flavor, cause i needed to replace words in certain parts of the strings and that's how i found perl.
but i don't know anything about programming, i would like to know simple examples how to use regular expression from the shell (terminal) or basic scripts.
for example if i have in a folder a text document called : input.txt how can i perform the following regex.
text to match :
text text text
text text text
what i want : change the second occurrence of the word text for the word: changed
(\A.*?tex.*?)text(.*?)$
replace for : \1changed\3
expected result:
text changed text
text changed text
using a text editor that would be using Multi-line and global modifiers. now, how can i process this from the shell. CD path and then what? or a script? what should contain to make it workable.
please consider i don't know anything about Perl, but only about its regexp syntax