1 / 19

Using Linux Commands(2)

Using Linux Commands(2). Lab 5. Creating files and directories. Use the command mkdir to create a new directory to the current working directory. $ mkdir directoryName. Creating files and directories. Go to your home directory. Type cd .

chas
Download Presentation

Using Linux Commands(2)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Using Linux Commands(2) Lab 5

  2. Creating files and directories • Use the command mkdir to create a new directory to the current working directory. • $ mkdirdirectoryName

  3. Creating files and directories • Go to your home directory. Type cd. • Make sure that you got to your home directory, type pwd • Create a new directory called test in your home directory: • Check the permissions of the directory by typing: • Suppose that you want to prevent everyone else from using or viewing the files in this directory: • Make the test directory your current directory :

  4. Creating files and directories • To create a directory(test) in the Desktop, we have two ways: • mkdir /home/chris/Desktop/test • cd /home/chris/Desktopmkdir test • NOTE: • The -d option tells ls not to list the contents of the test directory; just show us the listing for the directory itself.

  5. Moving, copying, and deleting files

  6. Moving, copying, and deleting files *  remove all files in the current directory

  7. Create empty files • To create an empty file in the current directory use the command touch • $ touch file1 file2 file3 Using file-matching metacharacters • Metacharacters help to match one or more files without typing each filename completely. • * This matches any number of characters(zero or more characters). • ? This matches any one(single) character. • […] This matches any one of the characters between the brackets, which can include a dash-separated rang of letters or numbers.

  8. Using file-matching metacharactersThis matches any number of characters *

  9. Using file-matching metacharactersThis matches any one(single) character?

  10. Using file-matching metacharactersThis matches any one of the characters between the brackets […]

  11. Using file-redirection metacharacters • < Direct the contents of a file to the command • > Direct the output of a command to a file, overwriting any existing file • >> Direct the output of a command to a file, adding the output to the end of • existing file

  12. echo Command • Use echo command to display text or value of variable. echo [options] [string, variables...]

  13. Quotes • "Double Quotes“ • variables and command substitution(except \and $). • 'Single quotes‘ • protects everything enclosed between two single quote marks. • It is used to turn off the special meaning of all characters ( NOsubstitution of variables and commands). • `Back quote` • Used with commands only. • To execute command.

  14. echo Command • Options-nDo not output the trailing new line.-eEnable interpretation of the following backslash escaped characters in the strings: \a alert (bell)\b backspace\n new line\t horizontal tab

  15. Examples of quoting special characters

  16. Sort command • Sort the lines of text files. $ sort fileName • by default it will sort in normal order(alphabetical 0-9 A-Z ). • Options • -rReverse normal order(reverse alphabetical Z-A 9-0).-nSort in numeric order(Sorts by the beginning of the number at the beginning of the line.)-nrSort in reverse numeric order • Note that this command does not sort the actual file, it just displays the sorted output on your terminal.

  17. Sequential commands • To run a sequence of commands type several commands on the same command line and separating them with semicolons(;)

  18. References http://www.podgrid.org/linux-bible/linux-bible-page109.html

More Related