RE: Unix Scripting Question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> I thought we were talking about trailing whitespace at the end of the
> actual filenames, such as this...
>
> touch "/root/some file with trailing whitespace     "
>
> Is that your problem, or do you have trailing whitespace in your a.lst
> file, such as...
>
> "/etc/samba/smb.conf    "


Nevermind my last post, I misread what you said.  I wrote another Perl
script that will fix your a.lst file removing the trailing whitespace. 
Please make a backup of your a.lst file before running the script...



#!/usr/bin/perl

$file = '/root/testing/a.lst';
open(FILE, $file) or die "Can't open $file: $!\n";
@lines = <FILE>;
close FILE;

$new = 'b.lst';
open(NEW, ">$new") or die "Can't open $new for writing: $!\n";

foreach (@lines) {
  $_ =~ s/\s+$//g;
  print NEW "$_\n";
}

close NEW;




Chris Purcell, RHCE



-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux