≡ Menu

input file

Unix / Linux Shell: Parse Text CVS File Separator By Field

I work for a small ISP (Internet Service Provider) and we are using Linux and Unix-like operating system with bash shell. I want to write a shell script to parse the csv file line by line. Then line must be parse again field by field. The sample input file is as follows:


I need to extract each of these example.com,username,groupname,homedir,md5password,permission,secondarygroup fields and passed to the different system utilities. How do I write a shell script to automate this task and use the bash shell to parse a text file?
[click to continue…]

Howto: Send The Content Of a Text File Using mail Command In Unix / Linux

I‘d like to send an email with the content of a text file using mail command in Unix / Linux operating system. How do I do it?
[click to continue…]

awk / cut: Skip First Two Fields and Print the Rest of Line

I would like to skip first two or three fields at the the beginning of a line and print the rest of line. Consider the following input
    This is a test
    Giving back more than we take

I want my input file with the following output:
    a test
    more than we take

How do I printing lines from the nth field using awk under UNIX or Linux operating systems?
[click to continue…]

Bash Shell: Extract Digits From a String

How do I extract digits only from a given string under Bash shell?
[click to continue…]

Linux / UNIX: mplayer Play mp3s From a Playlist File

I‘m an extreme newbie to the Linux world, but any time I try to get play files according to a playlist file using mplayer command line it turns up this error:

$ mplayer playlist.m3u
MPlayer SVN-r1.0~rc3+svn20090426-4.4.3 (C) 2000-2009 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing playlist.m3u.
Cache fill: 0.00% (44 bytes)

Exiting… (End of file)

How do I fix this and play music without using GUI tools?
[click to continue…]

Grep From Files and Display the File Name

How do I grep from a number of files and display the file name only?
[click to continue…]

Bash Shell: Convert Tabs To Spaces In a File

How do convert tabs to spaces in a file using a bash shell?
[click to continue…]

Grep Count Lines If a String / Word Matches

How do I count lines if given word or string matches for each input file under Linux or UNIX operating systems?
[click to continue…]

Linux / UNIX Shell: Sort Date

Q. How do I sort date type of data stored in a text file which is in following sample format:

Code Date TIME
HOS05 23/12/2008 10AM
HOS06 15/12/2008 2PM
HOS62 29/12/2008 10AM
HOS64 23/12/2008 2PM
HOS70 26/12/2008 10AM
ZFT01 06/12/2008 10AM
HOS73 11/12/2008 2PM
MHOS051 05/12/2008 10AM
MHOS041 20/12/2008 2PM
MHOS042 27/12/2008 2PM
MHOS053 11/12/2008 10AM
MHOS043 30/12/2008 2PM

How do I sort data date and time wise?
[click to continue…]

Bash Shell: Replace a String With Another String In All Files Using sed and Perl -pie Options

How do I replace a string with another string in all files? For example, ~/foo directory has 100s of text file and I’d like to find out xyz string and replace with abc. I’d like to use sed or any other tool to replace all occurrence of the word.
[click to continue…]