Browsing all articles tagged with file
Dec
13

Tip: Remove Duplicate Lines in File Using Perl

Here is little nifty code I found to snip or remove duplicate lines in a file using Perl. An example of a file that has duplicate lines looks like this:

/home/index.php
/home/links.php
/home/index.php

The result we want to achieve is this:

/home/index.php
/home/links.php

And here goes the code:

$ftmp = 'file.txt';
my %match = ();
{
local @ARGV = ($ftmp);
local $^I = '.tmp';
while(<>){
$match{$_}++;
next if $match{$_} > 1;
print;
}
}

The original file, file.txt, has its duplicate lines removed.

Aug
12

Linux File Directory Structure

When I am introducing Linux to new users like students, I noticed that it takes time for the new user to get used to Linux, particularly the directory structure. Since most are Windows users, they know how the directory structure of Windows looks like, and expects that it will be the same with Linux. To properly illustrate the Linux directory structure, linuxconfig.org has an illustration of the Linux File Hierarchy for easy explanation:

Linux directory


Understanding the directory hierarchy of Linux will result in ease of navigation while running the OS, regardless of the distro (Ubuntu, Red Hat, Fedora, etc.).

Powered by 1and1.comGlobat Webhosting Earn with Your BlogAdvertise @ PinoyTux

Search PinoyTux

Subscribe to Email Feeds

Enter Email Address:

Blog Lounge

Popular Posts

Recent Posts

Drop your Card Here

Recent Comments

Site Stats