Centos sh 變數設定都有\r - Linux

By Freda
at 2015-09-02T18:05
at 2015-09-02T18:05
Table of Contents
使用的系統是 Centos 6.5
最近想寫一個shell script來抓取某資料夾下更新的檔案列表
目前這樣使用是可以的
(給予絕對路徑)
find /var/www/html/ -type f -exec stat --format '%Y :%y %n' "{}" \; | sort
-nr | cut -d: -f2- | head
但後來是想說~乾脆寫個變數在上面
這樣之後比較好去改
filesite=/var/www/html/
find $filesite -type f -exec stat --format '%Y :%y %n' "{}" \; | sort -nr |
cut -d: -f2- | head
但是一直失敗
原因是他寫
find: `/var/www/html/\r': No such file or directory
就怪了,\r不管我怎麼去想取代或是不同方式去定義變數
這個\r就是去不掉
不曉得此方法該如何解~~
先謝謝各位大大了...
--
最近想寫一個shell script來抓取某資料夾下更新的檔案列表
目前這樣使用是可以的
(給予絕對路徑)
find /var/www/html/ -type f -exec stat --format '%Y :%y %n' "{}" \; | sort
-nr | cut -d: -f2- | head
但後來是想說~乾脆寫個變數在上面
這樣之後比較好去改
filesite=/var/www/html/
find $filesite -type f -exec stat --format '%Y :%y %n' "{}" \; | sort -nr |
cut -d: -f2- | head
但是一直失敗
原因是他寫
find: `/var/www/html/\r': No such file or directory
就怪了,\r不管我怎麼去想取代或是不同方式去定義變數
這個\r就是去不掉
不曉得此方法該如何解~~
先謝謝各位大大了...
--
Tags:
Linux
All Comments

By Olivia
at 2015-09-06T18:57
at 2015-09-06T18:57

By Isabella
at 2015-09-08T02:04
at 2015-09-08T02:04

By Harry
at 2015-09-09T02:40
at 2015-09-09T02:40

By Adele
at 2015-09-12T21:37
at 2015-09-12T21:37

By Necoo
at 2015-09-16T21:49
at 2015-09-16T21:49

By Ida
at 2015-09-17T08:20
at 2015-09-17T08:20
Related Posts
centos 7 網路設定問題

By David
at 2015-09-02T09:30
at 2015-09-02T09:30
Shell Scripts for迴圈的小問題

By George
at 2015-09-02T03:15
at 2015-09-02T03:15
Shell Scripts for迴圈的小問題

By Sandy
at 2015-09-02T01:02
at 2015-09-02T01:02
掛上的 nfs 是否能轉成 xfs?

By Bethany
at 2015-09-01T22:41
at 2015-09-01T22:41
USB Disk

By Freda
at 2015-09-01T22:40
at 2015-09-01T22:40