[root@oldboyedu~]# cd /data/oldboyedu -bash: cd:/data/oldboyedu: No such file or directory
1.为何出现这样的错误
答:没有/data目录或者没有/data/oldboyedu/目录
2.如何解决这个错误呢?
[root@oldboyedu-36-02~]# mkdir -p /data/oldboyedu [root@oldboyedu-36-02~]# cd /data/oldboyedu [root@oldboyedu-36-02oldboyedu]# touch oldboy.txt
法一: [root@oldboyedu-36-02oldboyedu]# echo ‘I love studying Linux.‘ >oldboy.txt [root@oldboyedu-36-02oldboyedu]# cat oldboy.txt I lovestudying Linux. 法二: [root@oldboyedu-36-02oldboyedu]# cat >oldboy.txt I lovestudying linux. ^C [root@oldboyedu-36-02oldboyedu]# cat oldboy.txt I lovestudying linux. 法三: [root@oldboyedu-36-02oldboyedu]# vi oldboy.txt--a/i--esc--:wq 法四: [root@oldboyedu-36-02~]# cat >>oldboy.txt<<EOF > I lovestudying linux. > EOF
[root@oldboyedu-36-02oldboyedu]# cp -r /data /tmp/ [root@oldboyedu-36-02oldboyedu]# ls /tmp 9.txt b.txt data yum.log z.txt [root@oldboyedu-36-02oldboyedu]# cp -a /data /tmp/ cp:overwrite `/tmp/data/oldboyedu/oldboy.txt‘? y [root@oldboyedu-36-02oldboyedu]# ls /tmp/ 9.txt b.txt data yum.log z.txt
>>:1>>,追加标准输出重定向,不清除内容,新加内容到最后一行; >:1>,标准输出重定向,清除旧内容,加入新内容; 2>:错误输出重定向; 2>>:错误追加输出重定向; #:1)注释;2)代表root用户; .:./,当前目录; ..:../ ,当前目录的上级目录;
trainning fanbingbing lidao
请给出输出test.txt文件内容时,不包含trainning字符串的命令。
创建环境: 法一: [root@oldboyedu-36-02oldboyedu]# cat >>test.txt<<eof >training >fanbingbing > lidao > eof 法二: [root@oldboyedu-36-02oldboyedu]# echo "training fanbingbing lidao">test.txt [root@oldboyedu-36-02oldboyedu]# cat test.txt training fanbingbing lidao 不包含trainning字符串的命令 法一: [root@oldboyedu-36-02oldboyedu]# sed -n ‘2,3p‘ test.txt fanbingbing lidao 法二: [root@oldboyedu-36-02oldboyedu]# head -3 test.txt|tail -2 fanbingbing lidao 法三: [root@oldboyedu-36-02oldboyedu]# tail -3 test.txt|grep -v training fanbingbing lidao 法四: [root@oldboyedu-36-02oldboyedu]# grep -v ‘training‘ test.txt fanbingbing lidao 法五: [root@oldboyedu-36-02oldboyedu]# awk ‘NR==2,NR==3‘ test.txt fanbingbing lidao [root@oldboyedu-36-02oldboyedu]# awk ‘{if(NR>=2&&NR<=3)print $0"\n"}‘test.txt fanbingbing lidao 法六: [root@oldboyedu-36-02~]# awk ‘{if(NR==2||NR==3) print $0"\n"}‘ test.txt fanbingbing lidao 注意: [root@oldboyedu-36-02 ~]# awk‘{if(NR>=2||NR<=3) print $0"\n"}‘ test.txt training fanbingbing lidao
临时修改: [root@oldboyedu-36-02~]# alias rm=‘echo "alias rm=rm command is not allowed to use"‘ [root@oldboyedu-36-02~]# alias rm aliasrm=‘echo "alias rm=rm command is not allowed to use"‘ [root@oldboyedu-36-02~]# rm -f 1.txt alias rm=rmcommand is not allowed to use -f 1.txt 永久生效: 1)alias rm=‘echo rm command is not allowed to use‘(临时生效) 2)用vim将1)的内容写入到/etc/profile文件的最后一行 3)用source /etc/profile命令使文件永久生效 4)去/root/.bashrc下将alias rm=‘rm -i‘注释掉即#‘alias rm=‘rm -i‘’
注:ett.txt由seq 20 120 >ett.txt创建
创建模拟环境: [root@oldboyedu-36-02~]# seq 20 120 >ett.txt 法一: [root@oldboyedu-36-02~]# head -40 ett.txt|tail -11 法二: tail -72ett.txt|head -11 法三: sed -n‘30,40p‘ ett.txt 法四: awk‘NR==30,NR==40‘ ett.txt awk‘NR>=30&&NR<=40‘ ett.txt 法五: awk‘{if(NR>=30&&NR<=40) print $0"\n"}‘ ett.txt 注意:(取不出来) [root@oldboyedu-36-02 ~]# awk‘{if(NR==30||NR==40) print $0"\n"}‘ ett.txt 49 59
法一: [root@oldboyedu-36-02~]# sed -i ‘s#training#oldboy#g‘ test.txt [root@oldboyedu-36-02~]# cat test.txt oldboy fanbingbing lidao 法二:vi/vim test.txt --a/i--insert--esc--:wq
[root@oldboyedu-36-02~]# find /data/ -type f -name "*.txt" |xargs sed -i‘s#training#oldboy#g‘ [root@oldboyedu-36-02~]# find /data/ -type f -name "*.txt" -exec sed -i‘s#training#oldboy#g‘ {} \; [root@oldboyedu-36-02~]# sed -i ‘s#training#oldboy#g‘ `find /data/ -type f -name "*.txt"` [root@oldboyedu-36-02~]# sed -i ‘s#training#oldboy#g‘ $(find /data/ -type f -name "*.txt")
法一: find /oldboy/ -type f -name "*.log"-mtime +7 -size +1M |xargs -i cp {} /tmp/ 法二: find /oldboy -type f -name "*.txt" -mtime+7 -size +1M -exec cp {} /tmp/ \; 法三: cp ` find /oldboy -type f -name "*.txt" -mtime +7 -size+1M ` /tmp/ ===反引号 法四: cp $( find /oldboy -type f -name "*.txt" -mtime+7 -size +1M) /tmp/ 法五: find /oldboy -type f -name "*.txt" -mtime+7 -size +1M|xargs cp -t /tmp/
答: buffer:把数据写入内存,这时写入数据的内存空间称为缓冲区,简称缓冲; cache:从内存中读取数据,这时读取数据的内存空间称为缓存区,简称缓存; 总结:写缓冲,读缓存。
原文地址:http://dakaige517.blog.51cto.com/11912621/1923470