Saturday, August 25, 2007

Merge Lines From One or More Files

The paste command will merge corresponding lines from one or more files. Each file is treated as a column. Here are some examples to demonstrate its use.

# more city
Helena
Bosie
Olympia
Salem
Denver

# paste city city
Helena Helena
Bosie Bosie
Olympia Olympia
Salem Salem
Denver Denver

# more state
Montana
Idaho
Washington
Oregon
Colorado

# paste city state
Helena Montana
Bosie Idaho
Olympia Washington
Salem Oregon
Denver Colorado

Redirect output to file
# paste city state > CityState
# more CityState
Helena Montana
Bosie Idaho
Olympia Washington
Salem Oregon
Denver Colorado

No comments: