xargs

xargs

一世执手 提交于 2019-11-29 21:09:19
1 # 命令替换 2 -t 先打印命令,然后再执行 3 -i 用每项替换 {} 4 find / -perm +7000 | xargs ls -l # 将前面的内容,作为后面命令的参数 5 seq 1 10 |xargs -i date -d "{} days " +%Y-%m-%d # 列出10天日期 来源: https://www.cnblogs.com/alog9/p/11532604.html

What is the PowerShell equivalent to this Bash command?

雨燕双飞 提交于 2019-11-29 14:09:53
问题 I'm trying to create a CLI command to have TFS check out all files that have a particular string in them. I primarily use Cygwin, but the tf command has trouble resolving the path when run within the Cygwin environment. I figure PowerShell should be able to do the same thing, but I'm not sure what the equivalent commands to grep and xargs are. So, what would be the equivalent PowerShell version to the following Bash command? grep -l -r 'SomeSearchString' . | xargs -L1 tf edit 回答1: Using some

ls: terminated by signal 13 when using xargs

丶灬走出姿态 提交于 2019-11-29 13:22:02
I'm using the following command to delete four largest size files in a folder: find "/var/www/site1/" -maxdepth 1 -type f | xargs ls -1S | head -n 4 | xargs -d '\n' rm -f It works fine, but from time to time throws broken pipe error: xargs: ls: terminated by signal 13 planetmaker I ran across a similar issue and found this thread on search for an answer: Signal 13 means something is written to a pipe where nothing is read from anymore (e.g. see http://people.cs.pitt.edu/~alanjawi/cs449/code/shell/UnixSignals.htm ). The point here is that the ls command as executed by xargs is still writing

Linux下查看文件和文件夹大小 删除日志

守給你的承諾、 提交于 2019-11-29 03:12:00
场景:在sts中执行自动部署时候maven提示No space left on device错误,后来经检查发现是磁盘空间满了,用下面的方法分析发现tomcat下面的logs目录占用了很大的空间,删除多余的日志问题解决! 1 Linux下查看文件和文件夹大小 当磁盘大小超过标准时会有报警提示,这时如果掌握df和du命令是非常明智的选择。 df可以查看一级文件夹大小、使用比例、档案系统及其挂入点,但对文件却无能为力。 du可以查看文件及文件夹的大小。 两者配合使用,非常有效。比如用df查看哪个一级目录过大,然后用df查看文件夹或文件的大小,如此便可迅速确定症结。 下面分别简要介绍 1.1 df命令 //可以用来查看分区的文件系统 df -T df命令可以显示目前所有文件系统的可用空间及使用情形 ,请看下列这个例子: df -h 参数 -h 表示使用「Human-readable」的输出,也就是在档案系统大小使用 GB、MB 等易读的格式。 上面的命令输出的第一个字段(Filesystem)及最后一个字段(Mounted on)分别是档案系统及其挂入点。我们可以看到 /dev/sda1 这个分割区被挂在根目录下。 接下来的四个字段 Size、Used、Avail、及 Use% 分别是该分割区的容量、已使用的大小、剩下的大小、及使用的百分比。 FreeBSD下,当硬盘容量已满时

【Linux】史上最全的Find命令

☆樱花仙子☆ 提交于 2019-11-29 02:43:28
Find 功能说明 :查找文件或目录。 语  法:find (-$) 参  数 && 说  明: [目录...] [-amin <分钟>] 查找在指定时间曾被存取过的文件或目录,单位以分钟计算 [-anewer <参考文件或目录>] 查找其存取时间较指定文件或目录的存取时间更接近现在的文件或目录 [-atime <24小时数>] 查找在指定时间曾被存取过的文件或目录,单位以24小时计算 [-cmin <分钟>] 查找在指定时间之时被更改的文件或目录 [-cnewer <参考文件或目录>] 查找其更改时间较指定文件或目录的更改时间更接近现在的文件或目录 [-ctime <24小时数>] 查找在指定时间之时被更改的文件或目录,单位以24小时计 [-daystart] 从本日开始计算时间 [-depyh] 从指定目录下最深层的子目录开始查找 [-empty] 寻找文件大小为0 Byte的文件,或目录下没有任何子目录或文件的空目录 [-exec <执行指令>] 假设find指令的回传值为True,就执行该指令 [-false] 将find指令的回传值皆设为False [-fls <列表文件>] 此参数的效果和指定"-ls"参数类似,但会把结果保存为指定的列表文件 [-follow] 排除符号连接 [-fprint <列表文件>] 此参数的效果和指定"-print"参数类似

Linux Shell 文本处理工具集锦

百般思念 提交于 2019-11-28 23:57:12
本文将介绍Linux下使用Shell处理文本时最常用的工具: find、grep、xargs、sort、uniq、tr、cut、paste、wc、sed、awk; 提供的例子和参数都是最常用和最为实用的; 我对shell脚本使用的原则是命令单行书写,尽量不要超过2行; 如果有更为复杂的任务需求,还是考虑python吧; find 文件查找 查找txt和pdf文件 find . \( -name "*.txt" -o -name "*.pdf" \) -print 正则方式查找.txt和pdf find . -regex ".*\(\.txt|\.pdf\)$" -iregex: 忽略大小写的正则 否定参数 查找所有非txt文本 find . ! -name "*.txt" -print 指定搜索深度 打印出当前目录的文件(深度为1) find . -maxdepth 1 -type f 定制搜索 按类型搜索: find . -type d -print //只列出所有目录 -type f 文件 / l 符号链接 按时间搜索: -atime 访问时间 (单位是天,分钟单位则是-amin,以下类似) -mtime 修改时间 (内容被修改) -ctime 变化时间 (元数据或权限变化) 最近7天被访问过的所有文件: find . -atime 7 -type f -print 按大小搜索

xargs with multiple arguments

半城伤御伤魂 提交于 2019-11-28 18:32:22
I have a source input, input.txt a.txt b.txt c.txt I want to feed these input into a program as the following: my-program --file=a.txt --file=b.txt --file=c.txt So I try to use xargs , but with no luck. cat input.txt | xargs -i echo "my-program --file"{} It gives my-program --file=a.txt my-program --file=b.txt my-program --file=c.txt But I want my-program --file=a.txt --file=b.txt --file=c.txt Any idea? Ole Tange None of the solutions given so far deals correctly with file names containing space. Some even fail if the file names contain ' or ". If your input files are generated by users, you

xargs doesn't recognize bash aliases

 ̄綄美尐妖づ 提交于 2019-11-28 17:43:34
I'm trying to run the following command: find . -iname '.#*' -print0 | xargs -0 -L 1 foobar where "foobar" is an alias or function defined in my .bashrc file (in my case, it's a function that takes one parameter). Apparently xargs doesn't recognize these as things it can run. Is there a clever way to remedy this? Since only your interactive shell knows about aliases, why not just run the alias without forking out through xargs ? find . -iname '.#*' -print0 | while read -r -d '' i; do foobar "$i"; done If you're sure that your filenames don't have newlines in them (ick, why would they?), you

Use xargs to mv a directory from find results into another directory

旧城冷巷雨未停 提交于 2019-11-28 17:30:52
问题 I have the following command: find . -type d -mtime 0 -exec mv {} /path/to/target-dir \; This will move the directory founded to another directory. How can I use xargs instead of exec to do the same thing. 回答1: If you've got GNU mv (and find and xargs ), you can use the -t option to mv (and -print0 for find and -0 for xargs ): find . -type d -mtime -0 -print0 | xargs -0 mv -t /path/to/target-dir Note that modern versions of find (compatible with POSIX 2008) support + in place of ; and behave

Batch renaming files in command line and Xargs

北慕城南 提交于 2019-11-28 16:43:54
So, I have the following structure: . .. a.png b.png c.png I ran a command to resize them ls | xargs -I xx convert xx -resize xx.jpg Now my dir looks like this . .. a.png.jpg a.png b.png.jpg b.png c.png.jpg c.png The firs question is, how do i rename the file so that I can just have one extension. Not two. (basically, how do I clean up my original mistake)? The second question is, in the future, using xargs, how do I change the extension of the file simular to second command? how do i rename the file so that I can just have one extension. cd dir/with/messedup/files for file in *.png.jpg; do mv