Active IQ Unified Manager Articles and Resources

Workflow example: Remove blank lines, lines with just whitespace, and beginning whitespace of each line from /etc/hosts

bdave

Simple workflow that contains a single command that backs up [/vol/vol0]/etc/hosts to [/vol/vol0]/etc/hosts.wfabak then overwrites [/vol/vol0]/etc/hosts, removing any blank lines or any lines that only contain whitespace, as well as beginning whitespace of each line.

 

(Designed for 7-mode.)

 

Updated.  Seems Read-NaFile reads all lines as a single string, so regular expressions treat the entire file as one line.  Doh!

 

Update 2:  More important than removing blank lines was removing the whitespace before the IP address of each line.

 

Thanks,

Dave

Please Note:

All content posted on the NetApp Community is publicly searchable and viewable. Participation in the NetApp Community is voluntary.

In accordance with our Code of Conduct and Community Terms of Use, DO NOT post or attach the following:

  • Software files (compressed or uncompressed)
  • Files that require an End User License Agreement (EULA)
  • Confidential information
  • Personal data you do not want publicly available
  • Another’s personally identifiable information (PII)
  • Copyrighted materials without the permission of the copyright owner

Continued non-compliance may result in NetApp Community account restrictions or termination.

Replies
manishks

Hi Dave,

   I tried working on this Automation to test the functionality on a lab filer before executing in our environment (330+ NTAP IT filers) . It did created a backup file of hosts /vol/vol0/etc/hosts.wfabak but did not remove the blanks lines and leading white spaces.

Any comments.

Regards

Manish

bdave

Hi Manish,

Thanks for letting me know about your experience.  Please try the updated version.  There was a problem in the first version.

Cheers,

Dave

hill

Great stuff Dave.  Nice work cranking this out!

All Community Forums
Public