Category Archives: Fedora

Post installation procedure for my fedora 24

This is the detailed log of my post installation procedures for Fedora 24.

In the Settings,
In Privacy, changed Usage and History – off, Location services – off
Region and Language, added input sources Malayalam
In Search unselected everything inside
Universal Access set Large text on

Install RPMFusion
Free and NonFree
su -c 'dnf install http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm'

Install FFmpeg and GStreamer
Skipped installing gstreamer-extras, other gstreamer plugins were already installed.
dnf install gstreamer1-plugins-ugly gstreamer1-plugins-bad-freeworld ffmpeg

Install Gnome Tweak Tool
dnf install gnome-tweak-tool
Enabled the Application and Places menu, Min Max buttion, Middle click lower.

Install Libdvdcss, HandBrake, Vlc
dnf config-manager --add-repo=http://negativo17.org/repos/fedora-handbrake.repo
dnf install libdvdcss HandBrake-gui vlc

Install Flash.
**Skipped**

Installing Chrome
Downloaded the Chrome RPM from Google.
dnf install google-chrome-stable_current_x86_64.rpm

Install Gimp, GFtp, Gparted
dnf install gimp gparted gftp

Install LM Sensors, Nethogs
dnf install lm_sensors nethogs

Disabled PackageKit automatic downloading of updates
gsettings set org.gnome.software download-updates false

Setup Thundirbird
dnf install thunderbird
Copy the contents of the backed up profile folder (xxxxx.default) to the new profile folder
Disabled the mail downloadin Synchronising as the mails were being downloaded again.

Work on fonts/scaling
Changed the default fonts in Chrome to Serif, Serif and Sans and Size to 17.
Changed the font size in FireFox to 17.

Install Xboard
dnf install xboard
Replace the .xboardrc and .icsrc file from backup
Create a custom desktop shortcut to use Dreamer engine
Copy the XBoard.desktop from /usr/share/applications to ~/.local/applications and modify the command property with xboard -fe Dreamer

The Linux Filesystem basics Part two

A filesystem can become ‘full’ and ‘run out of space’ either by (1) running out of all the free bytes, or (2) it can use up all the available inodes even when space is left for adding data.

Thought of making a test filesystem and check this.

We begin by making a file of size 500KB to hold our test filesystem.

[tony@localhost ~]$ su -
Password: 
[root@localhost ~]# dd if=/dev/zero of=~/inodeimage.img bs=1k count=500
500+0 records in
500+0 records out
512000 bytes (512 kB) copied, 0.00167129 s, 306 MB/s
[root@localhost ~]# ls -l inodeimage.img 
-rw-r--r--. 1 root root 512000 Aug 26 22:06 inodeimage.img

Make this file a loop device to mount it as a disk and work on it.

[root@localhost ~]# losetup -f inodeimage.img    # -f assigns the first free loop device
[root@localhost ~]# losetup -a                   # list all loopdevices to see if it worked
/dev/loop0: [fd01]:33392 (/root/inodeimage.img)

Make our test filesystem using mkfs

[root@localhost ~]# mkfs /dev/loop0
mke2fs 1.41.14 (22-Dec-2010)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
64 inodes, 500 blocks
25 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=524288
1 block group
8192 blocks per group, 8192 fragments per group
64 inodes per group

Writing inode tables: done                            
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

Make a directory to mount our test filesystem, and mount it.

[root@localhost ~]# mkdir ~/inodetmp
[root@localhost ~]# mount -t ext2 /dev/loop0 ~/inodetmp

Check the free inodes and free space available on our test filesystem.

[root@localhost ~]# df -i ~/inodetmp/
Filesystem            Inodes   IUsed   IFree IUse% Mounted on
/dev/loop0                64      11      53   18% /root/inodetmp   #53 free inodes
[root@localhost ~]# df -h ~/inodetmp/
Filesystem            Size  Used Avail Use% Mounted on
/dev/loop0            487K   15K  447K   4% /root/inodetmp
[root@localhost inodetmp]# ls
lost+found

So 53 free inodes available. Lets fill that up by creating 53 small files.

[root@localhost inodetmp]# for i in {1..53} ;do dd if=/dev/zero of=file$i bs=1 count=1; done
1+0 records in
1+0 records out
..........
..........
1+0 records in
1+0 records out
1 byte (1 B) copied, 2.4928e-05 s, 40.1 kB/s

Now, lets try creating another file,

[root@localhost inodetmp]# touch newfile
touch: cannot touch `newfile': No space left on device

See that we have a lot of space remaining (393K free), but no inodes left. In essence our disk is ‘full’ and have ‘run out of space’.

[root@localhost inodetmp]# df -i ~/inodetmp/
Filesystem            Inodes   IUsed   IFree IUse% Mounted on
/dev/loop0                64      64       0  100% /root/inodetmp
[root@localhost inodetmp]# df -h ~/inodetmp/
Filesystem            Size  Used Avail Use% Mounted on
/dev/loop0            487K   69K  393K  15% /root/inodetmp

—————–

Ok. Lets now try to fill the disk by the other method, ie, by using all the available bytes.

Remove all those files,

[root@localhost inodetmp]# rm -f *
rm: cannot remove `lost+found': Is a directory
[root@localhost inodetmp]# df -h ~/inodetmp/
Filesystem            Size  Used Avail Use% Mounted on
/dev/loop0            487K   15K  447K   4% /root/inodetmp
[root@localhost inodetmp]# df -i ~/inodetmp/
Filesystem            Inodes   IUsed   IFree IUse% Mounted on
/dev/loop0                64      11      53   18% /root/inodetmp

We see that 53 inodes are free and 447K is available, lets make a file of that size.

[root@localhost inodetmp]# dd if=/dev/zero of=file bs=1k count=447
447+0 records in
447+0 records out
457728 bytes (458 kB) copied, 0.00132163 s, 346 MB/s
[root@localhost inodetmp]# df -h ~/inodetmp/
Filesystem            Size  Used Avail Use% Mounted on
/dev/loop0            487K  466K     0 100% /root/inodetmp

We now see that the ‘Available’ space is 0. But if you check carefully the output, we see that the disk ‘Size’ is 487K and ‘Used’ is 466K. So remaining 21K??

Lets try making another file,

[root@localhost inodetmp]# dd if=/dev/zero of=file2 bs=1K count=1
1+0 records in
1+0 records out
1024 bytes (1.0 kB) copied, 3.0609e-05 s, 33.5 MB/s

It was possible eventhough 0 space was shown available!
This is because 5% of disk space is reserved for super user use. And df doesnt show that space as available in its output. This explains the difference 21K.

Lets fill that up too,

[root@localhost inodetmp]# dd if=/dev/zero of=file2 bs=1k count=20
20+0 records in
20+0 records out
20480 bytes (20 kB) copied, 0.000121892 s, 168 MB/s

[root@localhost inodetmp]# df -h ~/inodetmp/
Filesystem            Size  Used Avail Use% Mounted on
/dev/loop0            487K  487K     0 100% /root/inodetmp
[root@localhost inodetmp]# df -i ~/inodetmp/
Filesystem            Inodes   IUsed   IFree IUse% Mounted on
/dev/loop0                64      13      51   21% /root/inodetmp

Try adding a 1byte file, it must fail.

[root@localhost inodetmp]# dd if=/dev/zero of=file3 bs=1 count=1
dd: writing `file3': No space left on device
1+0 records in
0+0 records out
0 bytes (0 B) copied, 0.000197034 s, 0.0 kB/s

See that we have a lot of inodes remaining (51 free ) but no bytes left. In essence our disk is ‘full’ and have ‘run out of space’.

—————

As we have inodes remaining, It might still be possible to create empty (size 0 bytes) files.

[root@localhost inodetmp]# touch emptyfile
[root@localhost inodetmp]# ls -l
total 485
-rw-r--r--. 1 root root      0 Aug 29 15:44 emptyfile
-rw-r--r--. 1 root root 457728 Aug 27 23:05 file
-rw-r--r--. 1 root root  20480 Aug 27 23:05 file2
drwx------. 2 root root  12288 Aug 26 22:06 lost+found

I was wondering where there is space to create the directory entry for this newly created filename. It seems that the filesystem reserves some datablocks for the use of directories when the filesystem is created. If more space is needed, it is allocated dynamically from the unused datablocks, if available.

Just wanted to see how many files can made before that reserved space gets filled up in our test filesystem.
We try to make 50 empty files with 255 character long random filename.

[root@localhost inodetmp]# for i in {1..50} ; do name=`cat /dev/urandom | tr -cd 'a-f0-9' | head -c 255`; touch "$name"; done

The screen scrolled and the script terminated displaying “No space left on the disk”

As we can see below, the reserved space was over with just 3 of our empty files.

[root@localhost inodetmp]# ls -1 | wc -l
7              # 3 new files were made, excluding the existing 4.

————

Thankyou, if you were patient to read so far! :D I appreciate it.

Batch resize of images in Linux

I always resize images to smaller resolutions and add an overlay text before uploading to Flickr.

This is a script to do it using ImageMagick

To resize,

#!/bin/sh

mkdir upload
for f in *.jpg
do convert $f -resize 1024x1024 upload/$f
done

This will resize all images such that the longest side is 1024px in length, preserving the aspect ratio.

To resize and add an overlay text,

#!/bin/sh

mkdir upload
for f in *.jpg
do convert $f -resize 1024x1024 -pointsize 15 -fill white -gravity southeast -annotate +10+10 'Your overlay text' upload/$f
done

This will add an overlay text at the bottom right corner of the image, in white colour and 15pt size.

Save the script as resize.sh to the directory containing your images. Make it an executable and run it.

[tony@localhost pics]$ chmod +x resize.sh 
[tony@localhost pics]$ sh resize.sh 

You can use this same technique to add a copyright tag, watermark text or your logo to your images.

For full details on image resizing, text positioning refer,
http://www.imagemagick.org/script/command-line-processing.php#geometry
http://www.imagemagick.org/Usage/annotating/
http://www.imagemagick.org/Usage/fonts/

Linux text processing tools – Part 2

This is my attempt to get familiar with the various text processing tools in Linux. I am also noting down several oneliners that i found elsewhere.
Its a continuation of my earlier post Linux text processing tools – Part 1

This is NOT written as a tutorial. For details on usage and options check man pages.

sort – sort lines of text files

Sorting is done based on one or more sort keys extracted from each line of input.
If no sort keys are specified, the entire line is taken as key.

some of the options for sort are,
-f (ignore case), -b (ignore leading blanks),-n (numerically sort), -r (reverse), -u (unique), -tx (where x is the delimiter), -k (used to specify keys) -o (output file)

[tony@localhost tmp]$ sort List.txt 
bbb
ccc
CCC
ddd
[tony@localhost tmp]$ sort -n age.txt
08mike
18john
23tony
60jose
[tony@localhost tmp]$ sort -bn
19
 9
06
  14   #press CTRL+D to stop inputting
06
 9
  14
19
[tony@localhost tmp]$ sort -c list.txt
sort: list.txt:2: disorder: aaa   #check whether sorted
[tony@localhost tmp]$ sort -m list.txt list2.txt 
   #merge sorted files, each file must be sorted previously.

[tony@localhost tmp]$ sort list.txt -o list.txt     #sorts and saves in the same file
[tony@localhost tmp]$ sort -R list.txt -o list.txt    #shuffle a list of lines

sort keys(or fields) are specified using the -k option with the syntax
-k m[,n] (start at field m, end at field n including it, or the end if n is omitted).
By default blank is used as the field separator. It can also be specified using -tx

Note that several of the options available can also be specified along with the key.

[tony@localhost tmp]$ sort -k 3b   
   #sort using key from 3rd field to end of line. #Ignore any blanks preceding 3rd field.
[tony@localhost tmp]$ sort -k2n,2   
   #this will sort numerically based on the 2nd field.

[tony@localhost tmp]$ sort -t : -k 2,2n -k 5.3,5.4 
   #Sort numerically on the second field and then sort alphabetically on the third 
   #and fourth characters of field five to break tie. Use `:' as the field delimiter.

[tony@localhost tmp]$ sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4 IP.txt
   #sort a list of IPv4 addresses.

Note: if you sometimes see strange sorting order(check below example), this is usually bcoz linux locale setting set to a non-POSIX locale. You could prefix sort (or any command) with ‘LC_ALL=c‘ to get the POSIX order.

[tony@localhost tmp]$ sort list
1 1
111
212
2 2
[tony@localhost tmp]$ LC_ALL=c sort list
1 1
111
2 2
212

 

——————————–

shuf – shuffle lines

[tony@localhost tmp]$ sort LIST | shuf
333   #shuf shuffles our sorted LIST
212
444
111
[tony@localhost tmp]$ shuf -i 1-4
2   #generates a shuffled list of numbers
3
4
1
[tony@localhost tmp]$ shuf -e clubs hearts diamonds spades
clubs
diamonds
hearts
spades
[tony@localhost tmp]$ shuf LIST -o LIST   #in place save

 

——————————–

uniq – Uniquify files

uniq discard adjacent duplicate lines. Non adjacent duplicate lines are not discarded. To discard non adjacent duplicate lines the file must be sorted before or we could use the sort -u command.

[tony@localhost tmp]$ cat list
aaa
bbb
bbb
ccc
bbb
[tony@localhost tmp]$ uniq list
aaa
bbb
ccc
bbb
[tony@localhost tmp]$ uniq -c list
      1 aaa   #prefixes repetition count
      2 bbb
      1 ccc
      1 bbb
[tony@localhost tmp]$ uniq -d list
bbb   #only repeated lines
[tony@localhost tmp]$ uniq -i list2
ccc   #ignores case when comparing

Fields or characters can be ignored before comparison, by using the -fn and -sn options.

[tony@localhost tmp]$ cat > list2
aa bb
ad bb
ad cc
ad dd
[tony@localhost tmp]$ uniq -f 1 list2
aa bb   #we skipped first field from comparison check
ad cc
ad dd
[tony@localhost tmp]$ uniq -s 4 list2
aa bb   #we skipped the first 4 characters
ad cc
ad dd
[tony@localhost tmp]$ uniq -s 2 -w 1 list2
aa bb   #-w option specifies number of characters to compare after
   # any characters and fields have been skipped

[tony@localhost tmp]$ sort file | uniq -c | sort -n
#displays the unique lines along with the number of times they occur

 

———————————–

comm -: Compare two sorted files line by line

Comm output 3 columns, the first two columns contain lines unique to the first and second file, respectively. The last column contains lines common to both.
The columns are separated by tabs. The files must be sorted before.

Option -1,-2.-3 can be specified to remove the corresponding column from output.

[tony@localhost tmp]$ cat > list
aaa   
bbb   # press CTRL+D to stop inputting
[tony@localhost tmp]$ cat > list2
bbb
bbb
ccc
[tony@localhost tmp]$ comm list list2
aaa
		bbb   #bbb is common to both
	bbb           #this bbb is only in list2
	ccc
[tony@localhost tmp]$ comm -32 list list2
aaa   #only the lines unique in first file.

 

————————————–

head – Output the first part (10 lines) of files

supports the options -nK, -cK where K is the number of lines or bytes to be printed.

[tony@localhost ~]$ head -n5 .bash_history #prints 1st 5 lines
su -
lspci
/etc/init.d/NetworkManager restart
/etc/init.d/NetworkManager status
tail -f /var/log/messages 
[tony@localhost ~]$ head -c10 .bash_history   #1st 10 bytes
su -
lspci
[tony@localhost ~]$ head -n-5 .bash_history #prints all but last 5 lines

 

—————————————

tail – Output the last part(10 lines) of files

tail supports -nk and -ck as in the case of head.
tail -f periodically (default 1sec) checks to read from the end of the line

[root@localhost ~]# tail -f /var/log/messages
   # is used to scan system messages especially when isolating a problem

 

—————————————
split – Split a file into pieces

Usage: split [OPTION] [INPUT [PREFIX]]

Split is generally used to split a file based on lines (-l LINES) or bytes (-b SIZE)
By default files are split by 1000 lines. The files are named by appending aa, ab, ac, etc. to PREFIX (if ommitted x is used)


[tony@localhost tmp]$ cat > file
aaa
bbb
ggg
ccc
kkk   # Press CTRL+D to stop inputting
[tony@localhost tmp]$ split -l2 file   #split into files with 2 lines
[tony@localhost tmp]$ head xa?   # viewing each of them
==> xaa <==
aaa
bbb

==> xab <==
ggg
ccc

==> xac <==
kkk

[tony@localhost tmp]$ split -b100KB thriller.ogg part 
   # splitting music file by size 100KB
[tony@localhost tmp]$ ls -l parta?
-rw-rw-r--. 1 tony tony 100000 Oct 12 14:47 partaa
-rw-rw-r--. 1 tony tony 100000 Oct 12 14:47 partab
-rw-rw-r--. 1 tony tony   9305 Oct 12 14:47 partac
[tony@localhost tmp]$ cat parta? > thriller2.ogg
   # Joining them back

 

—————————————

paste – merge lines of files

Paste joins file by horizontally by outputting lines consisting of the sequentially corresponding lines of each file specified.

[tony@localhost tmp]$ cat > Name
john
tom   # Press CTRL+D to stop inputting
[tony@localhost tmp]$ cat > Age
20
19
[tony@localhost tmp]$ paste Name Age
john	20
tom	19

-s opton pastes the lines of one file at a time rather than one line from each file.

[tony@localhost tmp]$ paste -s Name Age
john	tom
20	19

a delimiter list can be specified using -d

[tony@localhost tmp]$ paste -d ':-' Name Age Name
john:20-john
tom:19-tom

 

—————————————

join – join lines of two files on a common field

Usage: join [OPTION] FILE1 FILE2

Join outputs a line for each pair of input lines with identical join fields. Each output line consists of the join field, the remaining fields from FILE1, then the remaining fields from FILE2.
The default join field is the first, delimited by whitespace and leading blanks on the line are ignored;
Both files have to be sorted on the join field.

[tony@localhost tmp]$ cat > j1
a ac
b bc
c cd   # Press CTRL+D to stop inputting
[tony@localhost tmp]$ cat > j2
a acc
b bcc
c cdd
[tony@localhost tmp]$ join j1 j2
a ac acc
b bc bcc
c cd cdd
[tony@localhost tmp]$ cat >> j2
c dcccc
[tony@localhost tmp]$ join j1 j2
a ac acc
b bc bcc
c cd cdd
c cd dcccc

Join supports options like the (-1 N) join field in first file ,(-2 N) join field in sec file, (-i) ignore case, (-t x) separator in output, (-v N) print non joined lines of file 1[or 2]

[tony@localhost tmp]$ join -1 2 -2 1 -t '-' file1 file2
   # this joins based on 2nd field on first file and 1st field of sec file and uses - as separator in output

 

————————————

Linux text processing tools – Part 1

This is my attempt to get familiar with the various small yet powerful text processing tools in linux. I am also noting down several oneliners that i found elsewhere.

This is NOT written as a tutorial. For details on usage and options check man pages

tr – tanslate or delete characters

Usage: tr [OPTIONS] SET1 [SET2]

Options include -d (delete), -s (squeeze), -c (complement) etc.

tr supports certain sequences like, [:alnum:],[:alpha:],[:blank:],[:lower:],[:upper:] etc and regular expressions for SET

[tony@localhost tmp]$ tr g e
grgat
great   #pressing CTRL+D quits
[tony@localhost tmp]$ echo tgst | tr g e
test   #adding quotes around SETs are recommended
[tony@localhost tmp]$ echo taxt | tr 'xa' 'se'
test   #Note the translation, x to s and a to e
[tony@localhost tmp]$ echo abCDef | tr '[:lower:]' '[:upper:]'
ABCDEF
[tony@localhost tmp]$tr A-Z a-z
abCDe
abcde
[tony@localhost tmp]$ echo test | tr -d 'e'
tst
[tony@localhost tmp]$ echo abc44jk | tr -d  0-9
abcjk
[tony@localhost tmp]$ echo 12d34sS5c | tr -d  a-z
12345
[tony@localhost tmp]$ echo abCDef | tr -d  [:upper:]
abef
[tony@localhost tmp]$ tr -cd '[:alnum:]'   #strip all symbols
[tony@localhost tmp]$ echo ttest | tr -s 't' 
test
[tony@localhost tmp]$ echo tteesttt | tr -s 'et' 
test
[tony@localhost ~]$ tr -s '\n' #strip empty lines. 
[tony@localhost tmp]$ echo test | tr -c 'e' 'g'
geggg 
[tony@localhost tmp]$ tr -cs 'a-zA-Z0-9_' '\n'< source.c
   #extract keywords, identifiers and comments from C source. ofcourse not perfect!
[tony@localhost tmp]$ tr '[:lower:]' '[:upper:]' <small.txt  >big.txt
[tony@localhost tmp]$ tr -d '\r' <windows.txt  >linux.txt
[tony@localhost tmp]$ tr '\r' '\n' <mac.txt  >linux.txt

 

--------------------

nl - number lines

[tony@localhost tmp]$ cat > list.txt
aaa
bbb

ccc
[tony@localhost tmp]$ nl list.txt 
     1	aaa
     2	bbb

     3	ccc
[tony@localhost tmp]$ nl -ba list.txt 
     1	aaa # -b is numbering syle
     2	bbb
     3	
     4	ccc
[tony@localhost tmp]$ nl -i10 -nrz -s:: -v10 -w4 list.txt 
0010::aaa  #-i increment, -s separator, -v start no, -w width, -n is Format
0020::bbb
      
0030::ccc

 

----------------------

wc - print line, word, and byte counts

[tony@localhost tmp]$ wc list.txt list2.txt 
 3  3 12 list.txt   # the counts are line, word, bytes
 4  3 13 list2.txt
 7  6 25 total
[tony@localhost tmp]$ wc -m list.txt
12 list.txt   #character count
[tony@localhost tmp]$ wc -L sample.txt
82 sample.txt   #longest line length
[tony@localhost tmp]$ ls -1 | wc -l
13   #no of files in current directory
[tony@localhost tmp]$ ps -e | wc -l
178   #no of processes running
[tony@localhost tmp]$ cat /etc/group | wc -l
72

 

----------------------

cat - concatenate or write files, text or binary

[tony@localhost tmp]$ cat > list.txt
aaa

bbb
ccc   #press CTRL+D to stop inputting and save file
[tony@localhost tmp]$ cat list.txt 
aaa

bbb
ccc
[tony@localhost tmp]$ cat f1 f2
aaa
bbb
[tony@localhost tmp]$ cat f1 f2 > f3
[tony@localhost tmp]$ cat f3
aaa
bbb
[tony@localhost tmp]$ cat >> f3
ddd   #append input to file
[tony@localhost tmp]$ cat f1 - f2 > f3 
this is what i entered in the middle
[tony@localhost tmp]$ cat f3
aaa
this is what i entered in the middle
bbb
[tony@localhost tmp]$ cat video.001 video.002 video.003 > vid.avi
  # joining split binary files 

 

----------------------------

tac - concatenate or print in reverse (last line first)

[tony@localhost tmp]$ tac > f1
1
2   #press CTRL+D to stop
[tony@localhost tmp]$ tac f1
1
2
[tony@localhost tmp]$ tac vid.avi > vid2.avi ; mv vid2.avi vid.avi #it wont play
[tony@localhost tmp]$ tac vid.avi > vid2.avi ; mv vid2.avi vid.avi # back to playable. 
  #This is like a mini encryption for binary files.

 

----------------------------

rev — reverse lines of a file or files

[tony@localhost tmp]$ echo this is to be reversed | rev
desrever eb ot si siht
[tony@localhost ~]$ rev .bash_profile 
eliforp_hsab. #

snoitcnuf dna sesaila eht teG #
neht ;] crhsab./~ f- [ fi
crhsab./~ .	
if

smargorp putrats dna tnemnorivne cificeps resU #

nib/EMOH$:HTAP$=HTAP

HTAP tropxe

 

----------------------------

cut - remove sections from each line of files

cut can return section based on no: of bytes (-b), characters (-c), or fields (-f) when fields are separated by a delimiter(-d). Default delimiter is tab.

A range must be provided in each case which consists of one of N, N-M, N-(N to last) or -M (first to M)

[tony@localhost tmp]# cut -c 2-4 
abcdef #press CTRL+D to stop inputting
bcd
[tony@localhost tmp]# cut -c 3
abcdef
c
[tony@localhost tmp]$ cut -c 2,4,7
alongtext 
lne
[tony@localhost tmp]# cut -c -2
abcdef
ab
[tony@localhost tmp]# cut -c 2-
abcdef
bcdef
[tony@localhost tmp]$ cut -c 1,6-9,16-
alongtextwithnospaces
atextspaces
[tony@localhost tmp]# cut -f 2- -d ':'
23:34:45:56 # -d specifies delimiter
34:45:56
[tony@localhost tmp]$ cut -f 2
er rt fg wd ji      
er rt fg wd ji   #cut didnt find the delimiter (default is tab) 
   #so returns whole line
[tony@localhost tmp]$ cut -f 2 -s
er rt fg wd ji    #cut wont print as -s flag is used to
   # prevent printing when delimiter not found.
[tony@localhost tmp]$ cut -d: -f1 /etc/passwd >users.txt

 

-----------------------------

Continued on Linux text processing tools - Part 2