Have a Bash With This Linux Shell - page 2
Directing command output into a file is very useful. Some operations generate a lot of output; saving it in a file lets you study it at leisure. This command creates a new file, or replaces the contents of an existing file:
ls -al ~ > homefiles.txt
This creates a new file, or appends to the end of an existing file:
ls -al ~ >> homefiles.txtThis is a fast way to append lines to an existing file:
cat >> homefiles.txt testing, testing, new line
Hit CTRL + D to finish.
I like piping the output of make to a file, so I know what files were installed, and where. And to review any error messages. In this example, I'm installing JOE, Joe's Own Editor:
make install | tee joe-makeinstall.txt
The tee command is one of those odd little specialized Unix commands that come in handy at the strangest times. It both displays the command output on the screen, and stores it in a file. Use tee -a to append, instead of overwrite.
You doubtless noticed how most of the pieces of the above examples are not Bash features at all. The only Bash bits are:
cat < file1 > file2This works great when you're feeding a list, or other data in a file, to a script:
scriptname < filelist > outputfile.txt
Solid state disks (SSDs) made a splash in consumer technology, and now the technology has its eyes on the enterprise storage market. Download this eBook to see what SSDs can do for your infrastructure and review the pros and cons of this potentially game-changing storage technology.
- 1Linux Top 3: Ubuntu 14.04, Debian Gives Squeeze More Life and Red Hat Goes Atomic
- 2Linux Top 3: CoreOS, Oracle Enterprise Linux 7 and Ubuntu 14.10
- 3Linux Top 3: Debian Dumps SPARC, Ubuntu Takes Over Linux 3.13 and the Core Infrastructure Initiative
- 4Linux Top 3: Fedora, Ubuntu and Gluster Lose Community Leaders
- 5Red Hat Enterprise Linux 7 Finally Hits the Big Time