我想在emacs-lisp中执行以下shell命令:
ls -t ~/org *.txt | head -5
Run Code Online (Sandbox Code Playgroud)
我尝试以下方面:
(call-process "ls" nil t nil "-t" "~/org" "*.txt" "| head -5")
Run Code Online (Sandbox Code Playgroud)
结果是
ls: ~/org: No such file or directory
ls: *.txt: No such file or directory
ls: |head -5: No such file or directory
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激.
我想将一堆dirs从DIR重命名为DIR.OLD.理想情况下,我会使用以下内容:
find . -maxdepth 1 -type d -name \"*.y\" -mtime +`expr 2 \* 365` -print0 | xargs -0 -r -I file mv file file.old
Run Code Online (Sandbox Code Playgroud)
但我要执行此操作的机器已安装BusyBox,而BusyBox xargs不支持"-I"选项.
有哪些常用的替代方法可以收集文件数组,然后在shell脚本中执行它们?
我知道以下内容可行:
hdiutil attach old.sparsebundle -mountroot .
diskutil rename old_label new_label
hdiutil detach old_label
hdiutil attach old.sparsebundle -mountroot .
Run Code Online (Sandbox Code Playgroud)
这会导致old_label被安装为new_label,但是安装它以重命名它然后卸载它并重新安装它以使标签生效是不优雅的.
还有另外一种方法吗?
给定一个字符串,我想用链接的描述替换其中的所有链接.例如,给定
this is a [[http://link][description]]
Run Code Online (Sandbox Code Playgroud)
我想回来
this is a description
Run Code Online (Sandbox Code Playgroud)
我使用re-builder为链接构建了这个正则表达式:
\\[\\[[^\\[]+\\]\\[[^\\[]+\\]\\]
Run Code Online (Sandbox Code Playgroud)
这是我的功能:
(defun flatten-string-with-links (string)
(replace-regexp-in-string "\\[\\[[^\\[]+\\]\\[[^\\[]+\\]\\]"
(lambda(s) (nth 2 (split-string s "[\]\[]+"))) string))
Run Code Online (Sandbox Code Playgroud)
它不是替换整个正则表达式序列,而是替换尾随的"]]".这就是它产生的:
this is a [[http://link][descriptiondescription
Run Code Online (Sandbox Code Playgroud)
我不明白出了什么问题.任何帮助将非常感激.
更新:我已经改进了链接的正则表达式.这与问题无关,但如果有人要复制它,他们也可以获得更好的版本.
我想rsync/Volumes/B /中的所有内容,除了Cache目录,我想全局排除.另外,我不想rsync任何其他/卷/
我有以下排除文件:
+ /Volumes/B/***
- Cache/
- /Volumes/*
Run Code Online (Sandbox Code Playgroud)
第一行和第三行似乎正常工作,除了rsync还获取/ Volumes/B/...(/Volumes/B/***/Cache/)下的所有缓存目录
我错过了什么?
我有一个脚本,输出时间戳,但我不能设法在达到特定行时评估日期; 所有邮票都有脚本第一次调用的时间,即它们都是一样的,即使脚本需要数小时才能完成.
我正在尝试这个:
TIMESTAMP=`date +"%H:%M:%S --"`
...
eval "echo $TIMESTAMP Starting backup"
...
eval "echo $TIMESTAMP Doing something here"
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
在elisp编码时,我发现在按字词移动时我会停在连字符处,并且宁愿忽略它们.
最简单的方法是什么?