Questions tagged [xargs]

xargs is a command on Unix and most Unix-like operating systems used to build and execute command lines from standard input.

xargs is a command on Unix and most Unix-like operating systems used to build and execute command lines from standard input. Under the Linux kernel before version 2.6.23, arbitrarily long lists of parameters could not be passed to a command, so xargs breaks the list of arguments into sublists small enough to be acceptable.

xargs often covers the same functionality as the backquote(`) feature of many shells, but is more flexible and often also safer, especially if there are blanks or special characters in the input. It is a good companion for commands that output long lists of files like find, locate and grep, but only if you use -0, since xargs without -0 deals badly with file names containing ', " and space.

1303 questions
-2
votes
3 answers

Shorten filename to n characters while preserving file extension

I'm trying to shorten a filename while preserving the extension. I think cut may be the best tool to use, but I'm not sure how to preserve the file extension. For example, I'm trying to rename abcdefghijklmnop.txt to abcde.txt I'd like to simply lop…
john
  • 11
  • 1
  • 5
-2
votes
1 answer

How do I use this cp command properly

How do I use the below properly: I want to find all files belonging to user and copy them in a folder. find / -user Joe | xargs -I {} cp {} /home/Joe/Folder The commands hangs and on ctrl C it prints a 0 that represents something.
-2
votes
4 answers

Can bash xargs plus bash paste output exactly 3 files, when using 5 input files?

Maybe xargs can do this maybe it can't, but it seems possible. The solution does not need to use xargs at all. Would prefer all bash commands but no python. It has to work on a massive number of input files though (only toy-size example is shown…
Geoffrey Anderson
  • 1,534
  • 17
  • 25
-2
votes
1 answer

How to -find -exec cp files from a list containing a portion of the filename

I've been searching for a long time and can't find an answer that works. I have a list with partial filenames (the first few letters of the filenames). If I place the file names individually as follows it works: find ~/directory/to/search -name…
RLz
  • 1
  • 1
-2
votes
1 answer

Multiple lines to single line in Linux

How to make the below given multiple lines to a single line in Linux? I am able to do with xargs but end of the every line has one space extra. From the below given output you can see 'JAS _Data' 'Exclusiv e' has a space. Thu Feb 19 10:42:50:…
-2
votes
1 answer

Limit of argument size of a command (for ex: in grep "$some_argument_size" filename)

I'm running a shell script and line# 15 is: grep "$var1$var2" somefilewithonly10000lines_letsay and getting an error: line 15: /bin/grep: Argument list too long What's the limit for the grep command's pattern? -- which when I reach, gives me the…
AKS
  • 16,482
  • 43
  • 166
  • 258
-2
votes
2 answers

what does xargs du -h do?

the command is find /etc -type f | xargs du -h I know that it basically means find all files in /etc but I'm not too sure on what the du -h does to it. Thanks.
-2
votes
1 answer

What does {} mean in the xargs command?

I want to move 1000000 files from a sources folder to destination folder using the this command: find /pacs/ccn15/ccn15_input/ccn1/(sources path) -name 'CDRCCN*' \ | head -100 |xargs -I mv '{}' /pacs/ccn10/ccn10_input/ccn1/(destination path) it…
user1363308
  • 938
  • 4
  • 14
  • 33
-3
votes
1 answer

How to execute several python scripts in parallel that use 2 GPUs and avoid cuda out of memory?

I have a bash file (generateData.sh) that contains hundred of python scripts such as : python create_video.py input output --param1 --param2 --param3 Each python script processes a different input video and uses in the process one of the two…
-3
votes
1 answer

How to clone repos inside a directory with their author name with REST API?

I'm using this bash & jq script: UserName=CHANGEME; \ curl -s https://api.github.com/users/$UserName/repos?per_page=1000 |\ jq -r '.[]|.clone_url' |\ xargs -L1 git clone It will clone the repos into a directory using the REST API parameter name…
Xyd
  • 123
  • 4
-3
votes
1 answer

I need to know what exactly this will do: (grep & xargs)

Here is the line: find /localdir/ | grep '[0-9']$ | xargs -i% cp % /tftpboot I specifically want to know what grep is looking for exactly here. Can anyone translate it for me please ? I am also kind of interested in what the xargs cmd is going to…
netDesign8
  • 77
  • 1
  • 8
-5
votes
1 answer

how to understand a shell script?

Can some explain me what the following does? find $FIRMWARE_BASE_DIR \( -name "*.txt" \) -type f | xargs -t -n1 sed -i '' -e '/^#/d;/^nocrc=/d;/macaddr=/d;/^$/d;s/[ \t]*$//'
Jeremyapple
  • 253
  • 2
  • 6
  • 20
1 2 3
86
87