#!/bin/bash # Write a shell script to combine any three text files into a single file # (append them in the order as then appear in the arguments) and display # the word count. # ------------------------------------------------------------------------- # Copyright (c) 2001 nixCraft project <http://cyberciti.biz/fb/> # This script is licensed under GNU GPL version 2.0 or above # ------------------------------------------------------------------------- # This script is part of nixCraft shell script collection (NSSC) # Visit http://bash.cyberciti.biz/ for more information. # ------------------------------------------------------------------------- file1=$1 file2=$2 file3=$3 out="output.$$" count=0 if [ $# -ne 3 ] then echo "$(basename $0) file1 file2 file3" exit 1 fi if [ ! -f $file1 ] then echo "$file1 not a file!" exit 2 fi if [ ! -f $file2 ] then echo "$file2 not a file!" exit 3 fi if [ ! -f $file ] then echo "$file3 not a file!" exit 4 fi cat $file1 $file2 $file3 >> $out count=$(cat $out | wc -w) echo "$count words written to $out"
Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our email newsletter to make sure you don't miss a single tip/tricks.
- Download Script
- Email this to a friend
- Printable version
- Rss Feed
{ 0 comments… add one now }