I need to write a script to show me all the alias I've set in certain config files like .tcshrc and some private script in case that I forget the meaning of alias like "a" , "b" , etc . the format of the aliases in the config file is either alias a "content of alias a" or alias b 'content of alias b' .
the code I wrote is as below :
#! /usr/bin/perl
open ( F , "<" , ".tcshrc" ) or die "can't open it; $! " ;
while ( <F> ) {
if ( /\b(alias\s+\w+\s+[\'\"][^\'\"]*[\'\"])/ ) {
print $1 ;
}
but the code doesn't work. So could any of you have a look at the code and tell me what's wrong with the reqex?
@Karel Bílek Yes, I missed the backslash at the second s, now it worked. but I'm still interested to know whether there is a better way to write the regex.
@Charles the lines I want to match is like
alias a 'ls -l'
alias b "rm *"