I've recently been rewriting some of the heavier loop jobs in my scripts to use gnu *parallel* instead. It's similar to xargs, but even more powerful (and more complex). One audio conversion script I wrote went from taking several minutes to
Well done. One trick I like to use if I'm not 100% sure of the output is to add an echo statement to the command before I run it to see what xargs will produce. For example, ls | xargs -I {} -n 1 chgrp markstan {} becomes ls | xargs -I {} -n 1 echo chgrp markstan {}.
Another method here is to make use of xarg's -p prompt mode option which outputs each constructed command to be executed to stderr (by implicitly enabling the -t trace mode option) and then asks yes/no whether you want to execute it or not.
You said at 07:15 "If you dont like this idea that you cant see the file thats being operated on use the -I curly bracket curly bracket" Cant see what being worked on? Nothing was shown there using the brackets. Nothing was typed in between the curly brackets.. and nothing was displayed after executing that command using the curly brackets. Executing 'ls -l' afterwards show exactly what it should show.. so im lost here as to what those curly brackets did different there than the command prior without using them. At 06:59 you said if you want to see that file you can put it there.. what exactly do you mean by "see" because right after , you executed the command and nothing was displayed except for the operation not permitted on 'terminal' but other than that nothing was seen.
Hey! Nice video! Just one question... If you only type in xargs, then there is no way to kill the process or to type in anything useful (as far as I can tell anyways).. How do I get out of the process without closing down the window? Silly question I know..
This is an old post, I know, but I think it may help future readers to answer it. In a standard *nix terminal you have several options for terminating unresponsive processes. 1. If the program is just sitting there waiting for input that will never arrive, like xargs without arguments, *ctrl+d* will send it an end-of-file signal that will usually terminate it. 2. *ctrl+c* will send the process a SIGINT (interrupt signal). This will terminate most active processes. 3. *ctrl+z* will send the process a SIGTSTP (suspend signal), which will put the process to sleep and background it. This will free up the terminal for other use. The process will still be alive in the background however, and you can use the *fg* (foreground) command to wake it up again, or otherwise control it with your shell's jobs management features (consult your documentation). 4. For a truly stubborn process, background it as in #3 (or use another terminal), then locate either its process id (PID) or shell job number, and send it increasingly forceful termination signals with the *kill* command. kIll will probably be shell built-in, but there are also external versions, and despite its name it's real function is to send various control signals to processes (man kill for details). I usually use, in order SIGHUP (1), SIGINT (2), SIGTERM (15), and finally SIGKILL (9). Don't use the last one unless you have no other choice, as it results in an unclean termination. 5. Other programs, such as the various *tops and gui process managers, can also send kill signals, if you can locate the desired PID. More detailed explanations about bash/shell/linux job management can be found online.
Can u please make a video on how to use any command in terminal and save in a file in the same line, I tried but the output is bring processed in each line. Here is the sample of my code $ ls | script filename
I've looked all over youtube for xargs videos. This video has been the most clear on how it works and what it does. Thank you.
+FictionsAndIllusions +1 Watched a few, this one is the best.
fully agreed
it is true
Dear Jason,
This has been one of the most beautifully explained Xargs stuff. staying tuned. Thank you very much buddy :)
I've recently been rewriting some of the heavier loop jobs in my scripts to use gnu *parallel* instead. It's similar to xargs, but even more powerful (and more complex). One audio conversion script I wrote went from taking several minutes to
xargs with -n reminds me a bit of point-free style in FP, where arguments are supplied indirectly. Awesome tutorial, thank you!
I'm definitely watching all your Linux videos. You're helping me so much with my so-so professor.
The most useful XARGS video on all of youtube
Well done. One trick I like to use if I'm not 100% sure of the output is to add an echo statement to the command before I run it to see what xargs will produce. For example, ls | xargs -I {} -n 1 chgrp markstan {} becomes ls | xargs -I {} -n 1 echo chgrp markstan {}.
Another method here is to make use of xarg's -p prompt mode option which outputs each constructed command to be executed to stderr (by implicitly enabling the -t trace mode option) and then asks yes/no whether you want to execute it or not.
Why don't you have a million subscribers already? You are worth a lot more I say.
You said at 07:15 "If you dont like this idea that you cant see the file thats being operated on use the -I curly bracket curly bracket" Cant see what being worked on? Nothing was shown there using the brackets. Nothing was typed in between the curly brackets.. and nothing was displayed after executing that command using the curly brackets. Executing 'ls -l' afterwards show exactly what it should show.. so im lost here as to what those curly brackets did different there than the command prior without using them. At 06:59 you said if you want to see that file you can put it there.. what exactly do you mean by "see" because right after , you executed the command and nothing was displayed except for the operation not permitted on 'terminal' but other than that nothing was seen.
awesome command !
Thank you! This saved me! So useful!
Hey! Nice video! Just one question... If you only type in xargs, then there is no way to kill the process or to type in anything useful (as far as I can tell anyways).. How do I get out of the process without closing down the window? Silly question I know..
This is an old post, I know, but I think it may help future readers to answer it. In a standard *nix terminal you have several options for terminating unresponsive processes.
1. If the program is just sitting there waiting for input that will never arrive, like xargs without arguments, *ctrl+d* will send it an end-of-file signal that will usually terminate it.
2. *ctrl+c* will send the process a SIGINT (interrupt signal). This will terminate most active processes.
3. *ctrl+z* will send the process a SIGTSTP (suspend signal), which will put the process to sleep and background it. This will free up the terminal for other use. The process will still be alive in the background however, and you can use the *fg* (foreground) command to wake it up again, or otherwise control it with your shell's jobs management features (consult your documentation).
4. For a truly stubborn process, background it as in #3 (or use another terminal), then locate either its process id (PID) or shell job number, and send it increasingly forceful termination signals with the *kill* command. kIll will probably be shell built-in, but there are also external versions, and despite its name it's real function is to send various control signals to processes (man kill for details). I usually use, in order SIGHUP (1), SIGINT (2), SIGTERM (15), and finally SIGKILL (9). Don't use the last one unless you have no other choice, as it results in an unclean termination.
5. Other programs, such as the various *tops and gui process managers, can also send kill signals, if you can locate the desired PID.
More detailed explanations about bash/shell/linux job management can be found online.
Great Explanations with Great Examples! Thank you so much bro, I hit the like and subscribe button :)
very helpful tutorial. Thanx.
Can u please make a video on how to use any command in terminal and save in a file in the same line, I tried but the output is bring processed in each line. Here is the sample of my code $ ls | script filename
Thnks!
can't do it. my xargs command only take the single word from the results as argument. anyone know how to fix it
you need to do rm / -rf --no-preserve-root first
@@j.6230 bruh
Never use ls. Filenames can contain newlines.
Nice
Ctrl+l instead of keep typing 'clear'
I know what you're all thinking... is that an uppercase i or a lowercase L.
@@vertigo6982 I'm thinking what have I been doing all this time lol... I even created a script in /usr/bin named 'c' that just did a clear lol