查看: 1284|回复: 0

[教程] 【一网打尽】Raspberry Pi Course Week 4 – Day 5 (File Manipulation)

[复制链接]
  • TA的每日心情
    开心
    2016-8-4 10:56
  • 签到天数: 242 天

    连续签到: 1 天

    [LV.8]以坛为家I

    发表于 2015-3-28 12:52:07 | 显示全部楼层 |阅读模式
    分享到:

    Create a file hello.txt by using the following command.

    $ touch hello.txt

    Confirm that the file has been created successfully by listing the files.

    $ ls

    To create a copy of this file, enter the following.

    $ cp hello.txt hellocopy.txt

    List the files to confirm that a copy of the file has been created.

    $ ls

    Remove the hellocopy.txt file by entering the following delete command.

    $ rm hellocopy.txt

    List the files again to confirm that the file has been removed.

    $ ls

    The terminal will blindly carry out your commands without asking you to confirm the file to delete.  If you want to be prompted when you delete a file enter the following.

    $ rm -i hello.txt

    Press N because there is an additional trick left.  Enter the following but this time you will press the tab file.

    $ rm -i he<PRESS TAB>

    This should complete the file in the command line to read.

    $rm -i hello.txt

    Press Y to delete the file.

    When create files it is always nice to keep things organised.  A directory will do just the job.  Enter the following.

    $ mkdir myfiles

    Create a file.

    $ touch suntimebox.txt

    List the files and folders to confirm that they have been created.

    $ ls -lF

    Move the suntimebox.txt file into the myfiles directory.

    $ mv suntimebox.txt myFiles

    List the files and folders again and take note that the suntimebox.txt file is missing.

    $ ls -lF

    It is missing from the current directory because it was moved into the myFiles directory.  Enter the following.

    $ cd myFiles

    $ ls -lF

    The file should appear in the directory that was created.  Enter the following.

    $ cd ..

    Enter the pwd command to confirm your locations.

    $ pwd

    Confirm that you are in the /home/pi directory and enter the following.

    $ rm myFiles

    The output displays that you cannot remove ‘myFiles’ because it is a directory.  This is because a flag is needed.  Enter the following command.

    $ rm myFiles -r

    This will attempt to remove any files inside the myFiles directory before removing it.


    回复

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条



    手机版|小黑屋|与非网

    GMT+8, 2024-4-25 06:41 , Processed in 0.110334 second(s), 15 queries , MemCache On.

    ICP经营许可证 苏B2-20140176  苏ICP备14012660号-2   苏州灵动帧格网络科技有限公司 版权所有.

    苏公网安备 32059002001037号

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.