xargs

Batch XSLT Transformation, find | xarg xsltproc

走远了吗. 提交于 2019-12-25 06:31:15
问题 I'd like to recursively find every "foo.xml" file and on each foo.xml apply the xslt bar.xsl and save over the original foo.xml. When I run the following commands, separately, they work. find . -name foo.xml xsltproc -o foo.xml bar.xsl foo.xml But, when I pipe them, nothing happens to foo.xml. find . -name foo.xml | xargs xsltproc -o foo.xml bar.xsl I think I'm missing something simple... Thanks, in advanced. 回答1: Warning both of these will obviously overwrite the xml's with the

Batch XSLT Transformation, find | xarg xsltproc

自闭症网瘾萝莉.ら 提交于 2019-12-25 06:31:10
问题 I'd like to recursively find every "foo.xml" file and on each foo.xml apply the xslt bar.xsl and save over the original foo.xml. When I run the following commands, separately, they work. find . -name foo.xml xsltproc -o foo.xml bar.xsl foo.xml But, when I pipe them, nothing happens to foo.xml. find . -name foo.xml | xargs xsltproc -o foo.xml bar.xsl I think I'm missing something simple... Thanks, in advanced. 回答1: Warning both of these will obviously overwrite the xml's with the

Need counter on find and xarg combo

て烟熏妆下的殇ゞ 提交于 2019-12-24 17:23:25
问题 So I have this code: find cobacoba -type f | xargs -n 5 bash -c 'a=(${0} ${1} ${2} ${3} ${4}); echo "File #: ${a[*]}";' Hoping Result: File #: cobacoba/1.3 cobacoba/1.6 cobacoba/1.q cobacoba/1.5 File #: cobacoba/1.1 cobacoba/1.q2 cobacoba/1.q23 cobacoba/1.4 File #: cobacoba/1.2 I would like to replace # with counter, like 1, 2, 3, so on... 回答1: You can postprocess your output with awk to replace # with the line number: find cobacoba -type f | xargs -n 5 bash -c 'a=(${0} ${1} ${2} ${3} ${4});

using xargs vim with gnu screen

强颜欢笑 提交于 2019-12-24 16:39:03
问题 I've got a weird problem where if i do something like this in a gnu screen window, that window starts responding in weird ways ls *.cpp | xargs vim After I exit from vim, the screen window doesn't echo any command. It even does not echo CR. Any suggestions? 回答1: Piping changes vim's stdin and causes problems. Try this instead (for bash, zsh, etc.): vim $(find . -name "*.cpp") 回答2: How about vim *.cpp ? Maybe for file in *.cpp; do vim "$file"; done could work too. Edit each file and exit. Or

Linux基础:xargs命令

谁说我不能喝 提交于 2019-12-24 12:00:11
简介 xargs可以将输入内容(通常通过命令行管道传递),转成后续命令的参数,通常用途有: 命令组合:尤其是一些命令不支持管道输入,比如ls。 避免参数过长:xargs可以通过-nx来将参数分组,避免参数过长。 使用语法如下 Usage: xargs [OPTION]… COMMAND INITIAL-ARGS… Run COMMAND with arguments INITIAL-ARGS and more arguments read from input. 入门例子 首先,创建测试文件 touch a.js b.js c.js 接着,运行如下命令: ls *.js | xargs ls -al 输出如下: -rw-r--r-- 1 a wheel 0 12 18 16:18 a.js -rw-r--r-- 1 a wheel 0 12 18 16:18 b.js -rw-r--r-- 1 a wheel 0 12 18 16:18 c.js 命令解释: 首先,ls *.js的输出为a.js b.js c.js。 通过管道,将a.js b.js c.js作为xargs的输入参数。 xargs命令收到输入参数后,对参数进行解析,以空格/换行作为分隔符,拆分成多个参数,这里变成a.js、b.js、c.js。 xargs将拆分后的参数,传递给后续的命令,作为后续命令的参数,也就是说

Bash: How to tail then copy multiple files (eg using xargs)?

我的梦境 提交于 2019-12-24 09:30:45
问题 I've been trying various combinations of xargs and piping but I just can't get the right result. Previous questions don't quite cover exactly what I want to do: I have a source directory somewhere, lets say /foo/source, with a mix of different files I want to copy just the csv files found in source to a different destination, say /foo/dest But I ALSO at the same time need to remove 232 header rows (eg using tail) I've figured out that I need to pipe the results of find into xargs, which can

how do I move specific files from one directory to other using xargs?

强颜欢笑 提交于 2019-12-24 05:37:24
问题 suppose I type this command: find /etc/info/ -name ".c" | xargs -I {} grep -l 'importantFile' {} Now I have all the files that I am interested, which has the suffix of .c and keywords "importantFile". How do I move it to one of my current directory(name: folder)? I tried: find /etc/info/ -name ".c" | xargs -I {} grep -l 'importantFile' {} mv{} ./folder and it doesn't work. Please help :p 回答1: If you like to stick with find, something like this should work: xargs -r0 --arg-file <(find . -name

Find (bash command) doesn't work with subprocess?

巧了我就是萌 提交于 2019-12-24 01:24:19
问题 I have renamed a css class name in a number of (python-django) templates. The css files however are wide-spread across multiple files in multiple directories. I have a python snippet to start renaming from the root dir and then recursively rename all the css files. from os import walk, curdir import subprocess COMMAND = "find %s -iname *.css | xargs sed -i s/[Ff][Oo][Oo]/bar/g" test_command = 'echo "This is just a test. DIR: %s"' def renamer(command): print command # Please ignore the print

Linux常用命令学习

放肆的年华 提交于 2019-12-23 17:10:11
1、ls命令 就是list的缩写,通过ls 命令不仅可以查看linux文件夹包含的文件,而且可以查看文件权限(包括目录、文件夹、文件权限)查看目录信息等等 常用参数搭配: ls -a 列出目录所有文件,包含以.开始的隐藏文件 ls -A 列出除.及..的其它文件 ls -r 反序排列 ls -t 以文件修改时间排序 ls -S 以文件大小排序 ls -h 以易读大小显示 ls -l 除了文件名之外,还将文件的权限、所有者、文件大小等信息详细列出来 实例: (1) 按易读方式按时间反序排序,并显示文件详细信息 ls -lhrt (2) 按大小反序显示文件详细信息 ls -lrS (3)列出当前目录中所有以“t”开头的目录的详细内容 ls -l t* (4) 列出文件绝对路径(不包含隐藏文件) ls | sed "s:^:`pwd`/:" (5) 列出文件绝对路径(包含隐藏文件) find $pwd -maxdepth 1 | xargs ls -ld 2、cd命令 (changeDirectory),命令语法:cd [目录名]。说明:切换当前目录至dirName 实例: (1)进入要目录 cd / (2)进入"家"目录 cd ~ (3)进入上一次工作路径 cd - (4)把上个命令的参数作为cd参数使用。 cd !$ 3、pwd命令 查看当前工作目录路径 实例: (1)查看当前路径

Using xargs command and two move commands following it

落爺英雄遲暮 提交于 2019-12-23 02:09:47
问题 OS: aix shell: bsh Hi, ppl I have two types of files, one type ends with .pdf.marker and the other ends with .pdf There should be always a pair with the same name (only the extensions are different). When I move a .pdf.marker file I must also move its corresponding .pdf file. I tried something like this: find ${INPUT_LOCATION}/ -name "*.pdf.marker" | xargs -I file mv file ${OUTPUT_LOCATION}/. mv $(basename file .marker) ${OUTPUT_LOCATION}/. Then I read this: xargs with multiple commands as