Mohammedz.com

For Linux and Shell scripting.

Linux commands: cut and paste

Leave a comment


cut and paste can be handy sometimes, especially when you have to manipulate
files based on rows and columns.

simple usages of cut and paste:

file1
******
first second
first second
first second

file2
******
3 4
3 4
3 4

Let me say, I want to cut first column of file2 and paste them as last column
of file1. Here you go

# cut -d” ” -f1 file2 |paste -d” ” file1 –
first second 3
first second 3
first second 3

what if the result from cut should be pasted at the beginning of file1?

# cut -d” ” -f1 file2 |paste -d” ” – file1
3 first second
3 first second
3 first second

~mohammed

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s