计算机课程中缺失的一课The missing semester in Computer Science Lecture 1

This course aims to teach students how to use the tools usually employed in daliy life.

Topic 1: The shell

We have to go old-school and drop down to a textual interface to make full use of the functions of a PC.What we need is shell.

Using the shell

My shell is like:

(base) myfile@192 ~ %

You can enter “data” to check the date.

(base) myfile@192 ~ % date
Wed Jun 22 21:39:05 CST 2022

Also we need to use echo to repeat the sentence:

(base) myfile@192 ~ % echo hello
hello
(base) myfile@192 ~ % which echo
echo: shell built-in command
(base) myfile@192 ~ % /bin/echo $PATH
/Users/myfile/opt/anaconda3/bin:/Users/myfile/opt/anaconda3/condabin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Library/Apple/usr/bin:/Users/myfile/Desktop/nand2tetris/tools

We can find out which file is excuted for a given program name using the w h i c h which which program. We can also bypass $PATH enitirely by giving the path to the file we want to execute.

Navigation in the shell

we can see the pwd command and change with the cd command. In a path, . refers to the current directory, and … to its parent directory.

(base) myfile@192 ~ % pwd
/Users/myfile
(base) myfile@192 ~ % cd /home
(base) myfile@192 /home % cd ..
(base) myfile@192 / % pwd
/
(base) myfile@192 / % cd ./home
(base) myfile@192 /home % pwd
/home

pwd shows the current path and cd means enter the new path.

(base) myfile@192 / % ls
Applications	Volumes		etc		sbin
Library		bin		home		tmp
System		cores		opt		usr
Users		dev		private		var
(base) myfile@192 / % cd
(base) myfile@192 ~ % cd ./Desktop
(base) myfile@192 Desktop % ls
MIT6.828
Old_Homebrew
PAT甲级刷题
Screen Shot 2022-06-02 at 10.35.44.png
XuanhaoZhao.github.io-main
d2l-zh-pytorch.pdf
github项目
hw3
nand2tetris
~$st a test.docx
~$词话-王国维.pdf.baiduyun.p.downloading
博客行
大学物理问题汇总
本科阶段文件
课外书
(base) myfile@192 Desktop % ls
MIT6.828				hw3
Old_Homebrew				nand2tetris
PAT甲级刷题				~$st a test.docx
Screen Shot 2022-06-02 at 10.35.44.png	博客行
XuanhaoZhao.github.io-main		大学物理问题汇总
d2l-zh-pytorch.pdf			本科阶段文件
github项目				课外书
(base) myfile@192 Desktop % 

ls will print the contents of the current directory.

mv(to rename / move a file)

cp(to copy a file)

mkdir(to make a new directory)

(base) myfile@192 ~ % man ls

Give the man program a try. It takes as an argument the name of a program, and shows you its manual page.Press q to quit.

Connecting programs
< file and > file let you rewire the input and output streams of a program to a file respectively.
(base) myfile@192 ~ % echo hello > hello.txt
(base) myfile@192 ~ % cat hello.txt
hello
(base) myfile@192 ~ % cat < hello.txt
hello
(base) myfile@192 ~ % cat hello.txt > hello2.txt
(base) myfile@192 ~ % cat hello2.txt
hello
(base) myfile@192 ~ % 

cat is a program that concatenates files.

  • 2
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值