小编eat*_*oaf的帖子

在Emacs-lisp中,在ls命令中使用call-process的正确方法是什么?

我想在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)

任何帮助将不胜感激.

lisp emacs

13
推荐指数
2
解决办法
3719
查看次数

xargs -l的替代品

我想将一堆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脚本中执行它们?

bash shell find xargs busybox

8
推荐指数
1
解决办法
7468
查看次数

是否可以在不安装/重命名/卸载/安装的情况下重命名sparsebundle卷标?

我知道以下内容可行:

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,但是安装它以重命名它然后卸载它并重新安装它以使标签生效是不优雅的.

还有另外一种方法吗?

filesystems macos diskimage timemachine

6
推荐指数
0
解决办法
3893
查看次数

在emacs-lisp中,如何正确使用replace-regexp-in-string?

给定一个字符串,我想用链接的描述替换其中的所有链接.例如,给定

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)

我不明白出了什么问题.任何帮助将非常感激.

更新:我已经改进了链接的正则表达式.这与问题无关,但如果有人要复制它,他们也可以获得更好的版本.

lisp regex emacs

5
推荐指数
1
解决办法
1160
查看次数

使用RSYNC,如何包含和排除组合?

我想rsync/Volumes/B /中的所有内容,除了Cache目录,我想全局排除.另外,我不想rsync任何其他/卷/

我有以下排除文件:

+ /Volumes/B/***
- Cache/
- /Volumes/*
Run Code Online (Sandbox Code Playgroud)

第一行和第三行似乎正常工作,除了rsync还获取/ Volumes/B/...(/Volumes/B/***/Cache/)下的所有缓存目录

我错过了什么?

rsync

5
推荐指数
1
解决办法
2644
查看次数

在Bash中,我怎么能懒惰评估'约会'?

我有一个脚本,输出时间戳,但我不能设法在达到特定行时评估日期; 所有邮票都有脚本第一次调用的时间,即它们都是一样的,即使脚本需要数小时才能完成.

我正在尝试这个:

TIMESTAMP=`date +"%H:%M:%S --"`
...

eval "echo $TIMESTAMP Starting backup"
...
eval "echo $TIMESTAMP Doing something here"
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

bash

3
推荐指数
1
解决办法
2235
查看次数

在Emacs中,如何从常见分隔符中排除" - "?

在elisp编码时,我发现在按字词移动时我会停在连字符处,并且宁愿忽略它们.

最简单的方法是什么?

emacs elisp

1
推荐指数
2
解决办法
125
查看次数

标签 统计

emacs ×3

bash ×2

lisp ×2

busybox ×1

diskimage ×1

elisp ×1

filesystems ×1

find ×1

macos ×1

regex ×1

rsync ×1

shell ×1

timemachine ×1

xargs ×1