Hi all, i have read in one site (i can put link, but is in Czech language
) that regular expressions have some kind of memory. If i understood it propertly when i want to remebmer some part of regexp i just put it between \( and ) and then call it by \1 \2 \3 etc. where \$number is number of memored expression. So i tried some examples bud didnt work for me
lets say i want to know only UID and HOME from /etc/passwd so i tried followings:
grep -E "^[^:]*:[^:]*:\([^:]*):[^:]*:[^:]*:\([^:]*):[^:]*" /etc/passwd
grep -E "^[^:]*:[^:]*:\([^:])*:[^:]*:[^:]*:\([^:])*:[^:]*" /etc/passwd
but neither one works. I know i didnt call \1 and \2 but i dont know how.
also tried append "end" string to end of all lines of file
sed -e 's/\(.*)/\1end/' file_name
with the same result as prevouis.
I know both tasks can be done using some other utils such as sed. But just for curiosity i want know more about regexp memory. Thanks a lot