[問題] 去掉文件的第一個字元

看板Linux作者 (麵T)時間12年前 (2013/11/12 23:53), 編輯推噓3(306)
留言9則, 6人參與, 最新討論串1/1
大家好, 我用 find /tmp /mnt /proc /backup/tar -name '*' ! -type d > exclude.filelist 得到如下的檔案內容: /sys/devices/platform/uevent /sys/devices/platform/power/wakeup /sys/devices/platform/pcspkr/uevent /sys/devices/platform/pcspkr/power/wakeup /sys/devices/platform/pcspkr/modalias 但我想把"每一行"的第一個'/'去除,請問有什麼相關的指令可以使用呢? -- 我是麵T,哩賀 http://ppt.cc/-eS5 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.117.196.151 ※ 編輯: noodleT 來自: 140.117.196.151 (11/12 23:53)

11/13 00:16, , 1F
你 find /tmp /mnt /proc /backup/tar 哪會得到 /sys/... ? XD
11/13 00:16, 1F

11/13 00:18, , 2F
你一開始 find 先 cd / 再 find tmp mnt ... 就不會有 / 帶頭
11/13 00:18, 2F

11/13 00:19, , 3F
或者 sed -i 's:^/::' exclude.filelist 內容就會去掉 / 帶頭
11/13 00:19, 3F

11/13 00:27, , 4F
謝謝,明天試試看
11/13 00:27, 4F

11/13 02:16, , 5F
vim 打開 ^v G d :wq 收工
11/13 02:16, 5F

11/13 09:12, , 6F
vim :%s/^.//g
11/13 09:12, 6F

11/13 09:53, , 7F
ls | cut -c2- ;
11/13 09:53, 7F

11/13 15:57, , 8F
@imcar 可以 :%s/.// 就好吧XD
11/13 15:57, 8F

11/13 23:59, , 9F
@imcar, 都加 ^ 了,又加 g 有啥特別原因嗎?
11/13 23:59, 9F
文章代碼(AID): #1IWaxeSx (Linux)