cat file1 file2 filen > outputfile
or if you want to concatenate all text files in directory:
or you can use >> operator to append to file:cat *.txt > outputfile
cat file1 >> file2
cat file1 file2 filen > outputfile
or you can use >> operator to append to file:cat *.txt > outputfile
cat file1 >> file2
wc -w <file>example for file 2600.txt (War and Peace from Leo Tolstoy) from Guttenberg Project :
wc -w 2600.txtoutput:
566321 2600.txtIf you want to count lines in some text file you could use:
wc -l <file>the same file for example
wc -l 2600.txtoutput:
65008 2600.txt
if ["$Var1" = "$Var2"]; then
echo "Variables Var1 and Var2 are equal!"
fi
if ["$Var1" = "$Var2"]; then
echo "Variables Var1 and Var 2 are equal!"
else
echo "Variables Var1 and Var2 are NOT equal!"
fi
#!/bin/bashThis simple example will output sentence Hello World!
Var1 = "Hello World!"
echo $Var1
#!/bin/bashThis simple example will put output from ls -la command in $Var1 variable and then print content on screen.
Var1= $(ls -la)
echo $Var1
local Var1="Local variable"
wget http://gutenberg.org/files/2600/2600.txt
tr A-Z a-zthen convert everything which is not small letter to new line
tr -cs a-z '\n'then sort result
sortfinally get unique words and count them:
uniq -c
and type this:nano wordcount
save and exit nano editor.cat "$@" | tr A-Z a-z | tr -cs a-z '\n'|sort|uniq -c
chmod +x wordcountand count words with
./wordcount <textfile>in this case:
./wordcount 2600.txtand we'll get words used in this great book and their number of appearances.
nano makedictand type this:
cat "$@" | tr A-Z a-z | tr -cs a-z '\n'|sort|uniqtake note that only difference between wordcount and makedict scripts is -c switch in uniq command.
chmod +x makedictand use:
./makedict 2600.txt