Difference between revisions of "Advanced Problems"

From FreekiWiki
Jump to navigation Jump to search
Line 5: Line 5:
 
[[CLI Variables]]
 
[[CLI Variables]]
  
==Piping==
+
== Piping ==
grep, less, wc, cat, multiple files, lsof, xargs, find, sort, awk
+
=== Commands ===
 +
grep = print lines matching a pattern
 +
less = view the contents of a text file
 +
wc    = print the number of newlines, words, and bytes in files
 +
cat   = concatenate files and print on the standard output
 +
find  = search for files in a directory hierarchy
 +
sort  = sort lines of text files
 +
 
 +
awk  = pattern scanning and text processing language
 +
lsof  = list open files
 +
xargs = build and execute command lines from standard input
 +
 
 +
=== The Pipe Character ===
 +
The pipe is a vertical bar, '|', it allows you to send the output from one command, as input to a second command. It allows you to combine two or more commands to process data using combinations of commands. It is very useful, but requires you to have a strong understanding of the commands that you're going to combine. As you use the command line more, you'll become more familiar with the commands and you'll start to understand which commands make sense to pipe together and which ones don't. Each side of the pipe is a an individual statement, with a command, possible options and possibly some other information that the command needs.
 +
 
 +
=== Examples ===
 +
#count the number of files in the ~/examples directory
 +
ls ~/examples | wc -w
 +
 
 +
'ls ~/examples' returns
 +
adv_cli  bash_script  basic_commands  c_example  media_example
 +
 +
'wc -w' counts the number of words (words are sets of characters surrounded by whitespace. So, when you combine the two you are counting the number of files that were listed.
  
 
==Networking==
 
==Networking==

Revision as of 13:42, 23 February 2008

Navigating

CLI Navigating

Variables

CLI Variables

Piping

Commands

grep  = print lines matching a pattern
less  = view the contents of a text file
wc    = print the number of newlines, words, and bytes in files
cat   = concatenate files and print on the standard output
find  = search for files in a directory hierarchy
sort  = sort lines of text files
awk   = pattern scanning and text processing language
lsof  = list open files
xargs = build and execute command lines from standard input

The Pipe Character

The pipe is a vertical bar, '|', it allows you to send the output from one command, as input to a second command. It allows you to combine two or more commands to process data using combinations of commands. It is very useful, but requires you to have a strong understanding of the commands that you're going to combine. As you use the command line more, you'll become more familiar with the commands and you'll start to understand which commands make sense to pipe together and which ones don't. Each side of the pipe is a an individual statement, with a command, possible options and possibly some other information that the command needs.

Examples

  1. count the number of files in the ~/examples directory
ls ~/examples | wc -w

'ls ~/examples' returns

adv_cli  bash_script  basic_commands  c_example  media_example

'wc -w' counts the number of words (words are sets of characters surrounded by whitespace. So, when you combine the two you are counting the number of files that were listed.

Networking

ifconfig, ping, wget, traceroute

While/For

write, touch

Apt

can we set up a xen instance to let students have root?

  • show studnets that they can have root in our current ltsp setup.
  • add the ability to have debian livecd over the net - or something like that.

Advanced Syntax

  • , --sort, &c.