2 檔案萬用字元,檔案建立 複製等操作

2021-07-22 09:50:23 字數 1808 閱讀 6481

變數$?,用於儲存命令執行成功與否的狀態,0表示成功,1-255表示失敗,以命令ls為例:

其他錯誤狀態,$?也會是非0結果。

使用反引號「或$()可引用其他命令的執行結果:

[root@localhost ~]# ls -d /var/l*[[:digit:]]*[[:lower:]]

/var/l13u /var/lfs3k

[root@localhost ~]# ls -d /etc/[[:digit:]]*[^[:digit:]]

/etc/222kkk /etc/333uuu

[root@localhost ~]# ls -d /etc/[^[:alpha:]][[:alpha:]]*

/etc/1djj

[root@localhost ~]# touch /tmp/tfile-`date +%f-%h-%m-%s`

[root@localhost ~]# touch /tmp/tfile-`date +%f-%h-%m-%s`

[root@localhost ~]# ls /tmp

tfile-2016-08-25-08-14-35 tfile-2016-08-25-08-14-36

[root@localhost ~]# mkdir /tmp/mytest1

[root@localhost ~]# cp -r /etc/p*[^[:digit:]] /tmp/mytest1/

[root@localhost ~]# ls /tmp/mytest1/

pam.d passwd passwd- pki plymouth pm popt.d postfix ppp prelink.conf.d printcap profile profile.d protocols

[root@localhost ~]# mkdir /tmp/mytest2

[root@localhost ~]# cp -r /etc/*.d /tmp/mytest2

[root@localhost ~]# ls /tmp/mytest2

bash_completion.d dracut.conf.d makedev.d prelink.conf.d rc1.d rc5.d statetab.d yum.repos.d

chkconfig.d init.d modprobe.d profile.d rc2.d rc6.d sudoers.d

cron.d ld.so.conf.d pam.d rc.d rc3.d rsyslog.d sysctl.d

depmod.d logrotate.d popt.d rc0.d rc4.d rwtab.d xinetd.d

[root@localhost ~]# mkdir /tmp/mytest3

[root@localhost ~]# cp -r /etc/[lmn]*.conf /tmp/mytest3

[root@localhost ~]# ls /tmp/mytest3

ld.so.conf libaudit.conf libuser.conf logrotate.conf mke2fs.conf nsswitch.conf

2 檔案 檔案操作

def fileno self,args,kwargs real signature unknown 返回檔案控制代碼在核心中的索引值,以後做io多路復用時可以用到 def flush self,args,kwargs real signature unknown 把檔案從記憶體buffer裡強制重...

2 檔案操作

新增檔案到版本庫 先保證檔案在之前建立的倉庫目錄下 第一步,用命令 git add告訴git,把檔案新增到倉庫 執行完後沒什麼顯示就對了 第二步,用命令 git commit告訴git,把檔案提交到倉庫 m後面輸入的是本次提交的說明,可以輸入任意內容 注意 commit可以一次提交很多檔案,所以你可...

1 檔案測試 2 檔案操作

1 檔案測試函式 2 檔案操作 新建檔案 fopen filename,w 以 寫 的方式開啟乙個不存在的檔案,就會新建該檔案 檔案刪除 unlink 檔案複製 copy filename,aaa bb.txt 盡量使用 和相對路徑,因為linux只認 也沒有磁碟分割槽,而windows 和 都認 ...