解答:[root@oldboy~]# mkdir /data
[root@oldboy ~]# cd /
[root@oldboy /]# ls
bin data etc lib lost+found mnt proc sbin srv tmp var
boot dev home lib64 media opt root selinux sys usr
解答[root@oldboy/]# touch /data/oldboy.txt
[root@oldboy /]# ls -l /data/oldboy.txt
-rw-r--r--. 1 root root 0 Mar 10 04:13/data/oldboy.txt
vi /vim
[root@oldboy /]# vi /data/oldboy.txt
I am studying linux.
[root@oldboy /]# cat /data/oldboy.txt
I am studying linux.
echo
[root@oldboy data]# echo "I am studyinglinux" >> /data/oldboy.txt
[root@oldboy data]# cat /data/oldboy.txt
I am studying linux .
解释:
#把echo的结果输出到 /data/oldboy.txt内
#输出到/data/oldboy.txt的最后一行
echo "Iam studying " >>/data/oldboy.txt
cat /data/oldboy.txt
>>表示把文件内容放到最后一行
>表示先清空文件内容,然后把你想要的内容追加到最后一行
cat
[root@oldboy /]# cat >> /data/oldboy.txt << EOF
> I am studying linux
> EOF
[root@oldboy /]# cat /data/oldboy.txt
I am studying linux
I am studying linux
解答:[root@oldboydata]# cp /root/data/oldboy.txt /tmp/
cp: overwrite `/tmp/oldboy.txt‘? y
[root@oldboy data]# ls /tmp/
oldboy.txt yum.log
解答:[root@oldboy34-nbdata]# mv /tmp/data /root
[root@oldboy34-nb data]# ls /root
anaconda-ks.cfg history.txt lrzsz-0.12.21-21.mga6.x86_64.rpm oldboy
data hudson nginx oldboy.txt
file01.txt hudson.txt nginx.conf test.txt
file.txt logon npp_7.3.2_Installer.exe
[root@oldboy34-nb data]# cd /data
[root@oldboy34-nb data]# ls
shahe.txt test.txt wangyao.txt
[root@oldboy34-nb data]# touch oldboy.txt
[root@oldboy34-nb data]# ls
oldboy.txt shahe.txt test.txt wangyao.txt
[root@oldboy34-nb data]# rm -f oldboy.txt
[root@oldboy34-nb data]# ls
shahe.txt test.txt wangyao.txt
[root@oldboy34-nb data]# cd /data
[root@oldboy34-nb data]# ls oldboy.txt
shahe.txt test.txt wangyao.txt
[root@oldboy34-nb data]# find ./ -type f-name "oldboy.txt" |xargs rm –f
[root@oldboy34-nb data]# ls
shahe.txt test.txt wangyao.txt
[root@oldboy34-nb data]# touch oldboy.txt
[root@oldboy34-nb data]# ls
oldboy.txt shahe.txt test.txt wangyao.txt
[root@oldboy34-nb data]# find ./ -type f-name "oldboy.txt" -exec rm -f {} \;
[root@oldboy34-nb data]# ls
shahe.txt test.txt wangyao.txt
解答:cd .. rmdirdata【rmdir 代表删除空目录,只能使用删除空目录】
[root@oldboy34-nb data1]# cd ..
[root@oldboy34-nb /]# rmdir data1
test
liyao
oldboy
请给出输出 test.txt文件内容时,不包含oldboy 字符串的命令。
[root@oldboy34-nb /]# cat test.txt
test liyao
oldboy
[root@oldboy34-nb /]# grep -v"oldboy" test.txt
test liyao
[root@oldboy34-nb /]# cat test.txt
test liyao
oldboy
[root@oldboy34-nb /]# sed ‘/oldboy/d‘test.txt
test liyao
解答:
[root@oldboyedu-35 ~]# mkdir -p /data/test
解答:[root@oldboy34-nb/]# mkdir -p /oldboy/test
[root@oldboy34-nb /]# ls
app data home lost+found oldboy proc selinux test usr
bin dev lib media oldgirl root srv test.txt var
boot etc lib64 mnt opt sbin sys tmp
[root@oldboy34-nb /]# ls -ld oldboy/
drwxr-xr-x. 3 root root 4096 Mar 14 10:16oldboy/
[root@oldboy34-nb /]#
\cp /mnt/test.txt /tmp/test.txt
/bin/cp /mnt/test.txt /tmp/test.txt
解答:[root@oldboy34-nb~]# alias
alias cp=‘cp -i‘
alias l.=‘ls -d .* --color=auto‘
alias ll=‘ls -l --color=auto‘
alias ls=‘ls --color=auto‘
alias mv=‘mv -i‘
alias rm=‘rm -i‘
alias which=‘alias | /usr/bin/which--tty-only --read-alias --show-dot --show-tilde‘
[root@oldboy34-nb ~]# alias rm=‘echo do notuse rm command‘
[root@oldboy34-nb ~]# rm /data
do not use rm command /data
解答:
解答:find/oldboy/ -type f “txt”
解答:cat/etc/passwd |wc –l
本文出自 “浅景尘” 博客,请务必保留此出处http://857803451.blog.51cto.com/12777961/1931506
原文地址:http://857803451.blog.51cto.com/12777961/1931506