Tuesday, November 5, 2013

Monday, October 14, 2013

Useful SED Examples

Append string on each line in a given file:
# sed 's/$/<string>/'  file.txt


Wednesday, October 2, 2013

A sample PowerCLI script for iterating multiple vCenters

Add-PsSnapin VMware.vimAutomation.core
$vcs=@()
$vcs +="vCenter1"
$vcs +="vCenter2"
$vcs +="vCenter3"
foreach ($vc in $vcs)
{
"Connecting to $vc"
Connect-VIServer -server $vc -user xxx -password xxx
"Connected to $vc"
}
...
Disconnect-VIServer *

Wednesday, January 23, 2013

Some SED tips for my records

To delete trailing whitespace from end of each line:
# sed 's/[ \t]*$//' filename > filename_notrailingspace

To remove all blank lines:
# sed '/^$/d' filename > filename_noblankspace

To remove all leading and trailing whitespace from end of each line:
$ cat filename | sed 's/^[ \t]*//;s/[ \t]*$//' > filename_nospace

Popular Posts

About Me

My photo
I have started this blog to share my work experience and spread some smart solutions on Linux to Internet community. I'm hoping more people will get benefited from this blog. Brief about me: I have 14+ years experience working as System Admin and currently work with VMware.