Skip to content

Latest commit

 

History

History
125 lines (93 loc) · 6.04 KB

File metadata and controls

125 lines (93 loc) · 6.04 KB

Linux Commands

Linux Tutorials and Introductions

Linux / UNIX References

Interesting Articles

The semi-colon (;) on the Linux Command Line

You can use a semicolon to separate UNIX commands on a single command line. This allows you do to things like put a time stamp on the output of a command.

$ ls -l ; date
total 64
-rwxrwxr-x 1 Wade None 54373 Jun 14 17:51 a.exe
-rwxrwxr-x 1 Wade None  1061 Jun 14 17:51 test.c
Sun, Jun 14, 2015  5:56:51 PM

grep

cron

Creating a file using the "cat" command

You can create a file with cat by redirecting output to a file. cat will read from stdin if no input file is given. ctrl-d ends input with a EOF.

$ cat > catfile
Here is a line.
Another line.
ctrl-d will put in an EOF.
$ cat catfile
Here is a line.
Another line.
ctrl-d will put in an EOF.

Keep in mind that this will erase anything in the file you are redirecting to. Most commands that accept a file as a parameter will attempt to read from stdin if no filename is given.

find

cut

Using Wildcards & Redirection

In UNIX, the wildcard * matches anything while ? will match a single letter. We can combine that with ls to get a list of files that, for example, start with h. The command "ls b?g" will list big, bag, bog, bkg, etc.

administrator@ubuntu:~$ ls h*
hello.c
administrator@ubuntu:~$ ls h?llo.c
hello.c
administrator@ubuntu:~$ ls h?ello.c
ls: cannot access h?ello.c: No such file or directory

We can also redirect output to a file using the ">" character. The following example creates a file called mydir that holds the results of the "ls" command

administrator@ubuntu:~$ ls > mydir
administrator@ubuntu:~$ cat mydir
220
240
a.out
Desktop
Documents
Downloads
examples.desktop
hello.c
Music
mydir
news.txt
Pictures
Public
Templates
Videos

bash shell notes

pipes

Advanced Topics