perl one-liners
(removes blank lines)
perl -pi -e 's/^$/BLANK/s ; s/^BLANK.*//s' pword
(creates blank line)
perl -pi -e 's/User1.*//g' /etc/passwd
(removes the line with User2&User1 and does not leave a blank line)
perl -pi -e 's/User2.*//s ; s/User1.*//s' pword
(removes blank line - single replacement)
perl -pi -e 's/User1.*//s' pword
(removes blank line as well)
perl -pi -e 's/^$/#/s ; s/^#.*//s' pword
(removes blank line with spaces or tabs)
perl -pi -e 's/^[ ]*$/#/s ; s/^#.*//s' pword
~
"Sep05-db-info.txt" 1525 lines, 38124 characters
-------------------------------------------
root@backupserver [/root/BackupDatabaseInfo]
-------------------------------------------
--> perl -pi -e 's/^[ ]*$/#/s ; s/^#.*//s' Sep05-db-info.txt
-------------------------------------------
root@backupserver [/root/BackupDatabaseInfo]
-------------------------------------------
--> cat Sep05-db-info.txt | wc -l
1461
|