The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 06-05-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
When text has leading whitespace, it replaces runs of n spaces with a tab character. Normally n should be 8, as that is the hardwired tab width of most terminals, but you can change it to something else if you need to. (I suspect you don't, though.)

The first parameter to wrap says how to indent the first line, and the second parameter says how to indent subsequent lines. If you want them indented by thirty spaces, try " " x 30 for the second parameter.


Code:
vnix$ perl -MText::Wrap -e 'print wrap(""," " x 30, <>)' /etc/motd | head -5
Linux indeed 2.6.24-17-generic #1 SMP Thu May 1 13:57:17 UTC 2008 x86_64
                              
                              The programs included with the Ubuntu system
                              are free software;
                              the exact distribution terms for each program


Last edited by era; 06-05-2008 at 03:11 AM.. Reason: Add example output