Ihr kennt doch sicher diesen Country-Song von Roger Miller über #xargs:
King of the Quote
🤓
Feels a bit dangerous, but I just dealt with #git complaining about local untracked files that would be overwritten by a `git pull` by selecting the list, copying it, then doing `pbpaste | xargs rm`. I assumed I'd get asked for confirmation for each one... but it just deleted them all! Eek! #bash #xargs
Ok. Remotely cleaning a huge (>2 TB, many many files and subdirs) #Nextcloud-hosted folder (not the whole user) is *painful*. Without access to the host it runs on I am limited to either the webinterface - which breaks - or using #webdav with a tool like #rclone.
#rclone purge breaks (timeout), so rclone delete it is. Which is *slow*, really slow. Probably because the remote moves a deleted file into the (for this case) useless trashbin which can't be turned off.
At least one can use #xargs to run multiple rclones in parallel - first get a list of entries of the to-be-deleted-dir (rclone lsf), format them the way rclone expects (basically put name of remote in front) and use something like `xargs -n 1 -P0 rclone delete -v --rmdirs` on it.
Still, its running since yesterday later afternoon and we are down to 1.4Tb left, of 2Tb. Even in parallel, the webdav shit manages to delete 2 to 4 files a second only.
#TIL: #xargs has an option -a to read items from a file instead of from standard input. This is perfect if you need to run xargs without a surrounding shell to provide the commonly used pipe mechanism, e.g. calling it just via exec() or similar.
My case today was with Perl's Test::Command::Simple::run_ok() in pxzgrep's TAP based test suite.
Today's Linux Tip: Execute Commands on Multiple Files in Linux #xargs #Linuxcommands #Linuxtips
#xargs bad. might elaborate later
@crmsnbleyd@emacs.ch thank you for having a solution without #xargs. it's a terrible program and there is always a way to avoid it that's more idiomatic to bash. /hj
fd, xargs, bat = quick document review
https://hiandrewquinn.github.io/til-site/posts/fd-bat-quick-document-review/
#ycombinator #xargs #bat #cli #automation #shell #selkouutiset_archive
@parvXtl the #xargs equivalent in #PowerShell is powerful and amazing, but not text-based. 😉
1. You can use the FullName property _inside_ the foreach-Object:
Get-ChildItem ~\Downloads -Recurse -File | ForEach-Object { perl .\bin\sanitize-file-name.pl $_.FullName }
2. But you don't need the FullName property in modern PowerShell -- it will pass the FullName of a file to a string parameter by default:
gci ~\Downloads -Recurse -File
| % {
perl .\bin\sanitize-file-name.pl $_
}
Context: https://tech.lgbt/@parvXtl/111470268924166649
"#xargs(1)" equivalent is painful in #MSWindows #Powershell; adapted from [0,1,2] to run with [3] ...
cd C:\Users\user
Get-ChildItem -Recurse '.\Downloads' -File -ErrorAction SilentlyContinue | ForEach-Object fullname | ForEach-Object { perl .\bin\sanitize-file-name.pl $_ }
... easier is to run in #WSL 1 ...
cd /mnt/C/Users/user
find ./Downloads/ -type f \
| xargs perl ./bin/sanitize-file-name.pl
# Use of wildcard.
Get-ChildItem -Recurse '.\dir' -Filter '*-*' ... | ...
... this exercise was specifically to find the Powershell syntax #FAFO #TheMoreYouKnow🌈🌟
To somewhat ease the pain, could change the program to take a list of directories with option to (not) recurse🤔🤷🏽♂️
---
0- Powershell glob pattern matching, 202112,
https://stackoverflow.com/questions/70355772/powershell-glob-pattern-matching
1- What's the equivalent of xargs in PowerShell?, 201605,
https://stackoverflow.com/questions/36428949/whats-the-equivalent-of-xargs-in-powershell
2- How to Filter Files and Folders Using PowerShell, https://www.delftstack.com/howto/powershell/filter-files-and-folders-using-powershell/#get-all-files-inside-subdirectories-using-get-childitem-cmdlet-in-powershell
3- Strawberry Perl, https://strawberryperl.com/
#parv_note
Bash has a way to specify strings with escaped characters like so: $'\r\n' which gives a string containing carriage return and newline characters.
The `read` built-in can take a delimiter with the -d flag. Combining these lets you use a null character: read -d $'\0'
Useful in some of the same places you might use xargs(1).
find . -name ... -print0 | while read -d $'\0'; do ./foo "$REPLY"; done
I nerd sniped myself last night with this GitHub issue https://github.com/codepo8/dearconsole/issues/11 🤣, which resulted in me running a #jekyll site locally for the first time and crafting this #cli command with #grep #xargs and #sed
grep -rl '^tags:.*,' ./_scripts | xargs sed -i '' '/^tags:/s/,//g'
W dzisiejszym, pierwszym w 2023 roku tutorialu z cyklu Porady Admina zajmiemy się programem xargs https://linuxiarze.pl/porady-admina-findutils-xargs/ #linux #porada #admin #findutils #xargs
Every shell has its weird quirks and nushell is no exception. Still getting used to it.
I certainly prefer the ease of use of each and par-each in nushell to xargs and GNU parallel.
https://www.nushell.sh/book/parallelism.html
I'm not willing to write any significant scripts in it yet, since the syntax could keep changing.
New #blog #post on the most aura surrounded #command #xargs
https://srinicame.blogspot.com/2021/05/xargs-generic-tool-for-arguments.html