Unix/Linux系统命令

来源:百度知道 编辑:UC知道 时间:2024/09/23 07:29:37
Write UNIX commands (on one line if you can) to:
a) display the present working directory
b) rename the file "foo.c" in the current directory to "oldfoo.c"
c) list the names all files with a single character file name body
(eg. a.cpp) in the current directory
d) list all files in the present working directory that have filenames
that match:
starts with a lowercase or uppercase letter
filename body ends with a digit
the extension is either .c or .h
e) Compress the files in the current directory and store them in
an archive called F.tar
f) sort the file /etc/passwd in reverse alphabetical order by
user description (field 5). Note: the fields of this file are
separated by the ":" character.
g) Add the lines of m which contain "file 1" to the file m1
h) delete the files with extension .o in your home directory
以上的题目是作业 跪求大师们的帮助啊啊啊~~~

a) pwd
b) mv foo.c oldfoo.c
c) ls [A-Za-z].*
d) ls [A-Za-z]*[0-9].[ch]
请查看正则表达式;
e) tar -cvf F.tar *
c表示创建,v即verbose,用于输出tar命令的执行过程,f指定归档后的文件名,而*表示当前目录下的所有文件(隐藏文件除外);
f) sort -rt: +4 -5 /etc/passwd
其中r表示逆序,t指定separator,"+4 -5"表示按第5个field排序;
g) grep "file1" m >> m1
其中>>是重定向符,表示将前一命令的输出追加到后一文件;
h) rm ~/*.o
~表示用户的home目录

是作业题的话应该去翻书。或者man tar;man sort;……