Tin học Việt

A place for learning and sharing knowledge


    [Unix/Linux] Lecture 2 - File Transfer and Working with Commands

    Share

    Admin
    Admin
    Admin

    Posts : 48
    Golds : 2147483647
    Liked : 16
    Ngày tham gia : 2011-08-25
    Tuổi : 20
    Đến từ : Ho Chi Minh City

    [Unix/Linux] Lecture 2 - File Transfer and Working with Commands

    Post by Admin on Tue Apr 07, 2015 9:35 pm

    Lecture 2 - File Transfer and Working with Commands


    I. File Transfer


    One easy way to create a file is using touch
    Some common options:
  • Change access time: -a
  • Change modification time: -m
  • Change date: -d

    For example:
    We want to modify time create of a file we do the following steps.
  • We create a file name New - touch New
  • We create a file name Old with date 01/01/1980 at 12:00 - touch -t 8001011200 Old (2 first digits is the year, next 4 digits is the date, last 4 digits is the time).
  • We set the modification time to New file by - touch -r old new

    *Working with file contents*
    clear (Ctrl + L): clear screen.
    cat: display contents of a file. Can also use to create text files by using cat > filename. You can choose an end marker for cat with << This construction is called a here directive and will end the cat command. And we can also use cat to copy contents of one file to another file cat file1 > file2
    tac: display contents from bottom to top of a file.
    less: writes the contents of a file onto the screen a page at a time. Press [space-bar] if you want to see another page, type [q] if you want to quit.
    more: After each page, asks the user to hit a key to continue. Can also jump to the first occurrence of a keyword (/ command).
    head -n: The command head writes the first n lines of a file to the screen.
    tail -n: The command head writes the last n lines of a file to the screen.
    wc: Word Count.

    • Current date/time is Tue Dec 06, 2016 3:40 am