summaryrefslogtreecommitdiffstats
path: root/reformat_fstab.pl
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2013-05-11 13:27:07 +0200
committerFlorian Pritz <bluewind@xinu.at>2013-05-11 13:27:07 +0200
commit60cb01f9a81c311f914aed4a23e8e5b35e965918 (patch)
tree8b9109a8f1bcf37506755e0e77b83b0a026cda57 /reformat_fstab.pl
parenta9ba01279e6f3c64b082f4de6e7d95cd1b5f7dab (diff)
downloadbin-60cb01f9a81c311f914aed4a23e8e5b35e965918.tar.gz
bin-60cb01f9a81c311f914aed4a23e8e5b35e965918.tar.xz
soem more cleanup
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'reformat_fstab.pl')
-rwxr-xr-xreformat_fstab.pl70
1 files changed, 0 insertions, 70 deletions
diff --git a/reformat_fstab.pl b/reformat_fstab.pl
deleted file mode 100755
index 9c81d8d..0000000
--- a/reformat_fstab.pl
+++ /dev/null
@@ -1,70 +0,0 @@
-#! /usr/bin/perl
-use warnings;
-use strict;
-
-my $fstabFile = shift;
-my $fstabOld;
-my $fstab;
-my @fstabLines;
-push @fstabLines, ['# <file system>', '<dir>', '<type>', '<options>', '<dump>', '<pass>'];
-my @lengths = map {length($_)} @{$fstabLines[0]};
-my $longestLine;
-
-open(my $fh, '<'. $fstabFile) or die "Unable to open $fstabFile: $!\n";
-while(defined(my $line =<$fh>))
-{
- $fstabOld .= $line;
- $longestLine = (length($line) > $longestLine) ? length($line) : $longestLine;
- if ($line =~ m/^#/ and $line !~ m/<file system>/)
- {
- $fstab .= $line;
- }
- elsif ($line =~ m/^#/ and $line =~ m/<file system>/)
- {
- next;
- }
- else
- {
- $line =~ s/ +/ /g;
- my @fields = split ' ',$line;
- push @fstabLines, \@fields;
- for (my $i; $i < scalar @fields; $i += 1)
- {
- if (length($fields[$i]) > $lengths[$i])
- {
- $lengths[$i] = length($fields[$i]);
- }
- }
- }
-
-}
-close $fh;
-
-my $printfStr = join '', map( {'%-'.($_+1).'s';} @lengths);
-
-foreach my $line (@fstabLines)
-{
- my @line = @{$line};
- $line = sprintf($printfStr, @line)."\n";
- $fstab .= $line;
- $longestLine = (length($line) > $longestLine) ? length($line) : $longestLine;
-}
-
-my $separator = ('-' x $longestLine)."\n";
-
-print "\n",$separator, "ORIGINAL FILE\n", $separator, $fstabOld, $separator, "REFORMATTED FILE\n", $separator, $fstab, $separator;
-
-print "Overwrite old file with new one? (y/n) ";
-my $ans = <>;
-chomp $ans;
-if ($ans eq 'y')
-{
- open(my $fh, '>', $fstabFile) or die "Unable to open $fstabFile: $!\n";
- print $fh $fstab;
- close $fh;
-}
-else
-{
- print "Exiting without saving...\n";
- exit;
-}