Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

bash xargs

# Basic syntax:
<command_1> | xargs <command_2>
# Where:
#	- the stdout of command_1 gets piped to xargs which executes command_2 on
#		every space, tab, or new-line-delimited input
# Note:
#	- this is similar to find..exec, but xargs is faster and more versatile
# 	- xargs allows tools like rm to accept standard input as arguments

# Example usage 1:
# Say you want to change the permissions of all directories and subdirectories
# of the current directory. You can run:
find . -type d | xargs chmod 777
# Note:
# 	- the -t flag causes xargs to print each command that will be executed
#		to the terminal, which is useful for debugging
#	- the -p flag will print the command to be executed and prompt the
# 		user to run it, which is also useful for debugging

# Example usage 2 (somewhat advanced):
find . -maxdepth 2 -type f -iname "*name*" | xargs -I {} sh -c "grep -l word1 $(grep -l word2 {})"
# Where:
#	- the find command identifies all files in the current directory and
#		subdirectories up to a depth of 1 that contain "name" in their
#		file name in a case-insensitive manner and pipes them to xargs
#	- -I specifies a string that will be replaced by the stdin when found (which
#		is useful for controlling where the piped content appears in the
#		xargs command)
#	- sh -c runs the shell command in quotes which can be used to do command
#		substitution in xargs
Comment

linux xargs

# xargs
## -d assign delimiter (defaul is blank char or 
)
xargs -d :
Comment

PREVIOUS NEXT
Code Example
Shell :: changing folder permission in linux 
Shell :: git pull with username and password linux 
Shell :: create file in linux using cat 
Shell :: view all of your git settings 
Shell :: ubuntu activate network interface on boot 
Shell :: install npm in windows 
Shell :: chmod 
Shell :: How to Block Ports in UFW Ubuntu Firewall 
Shell :: git a clean history 
Shell :: change resolution of a video with terminal 
Shell :: store pass git 
Shell :: replace whitespace with newline 
Shell :: ubuntu set vi as default editor 
Shell :: check if string starts with powershell 
Shell :: kali linux ping ip 
Shell :: wsl 2 installation 
Shell :: where to find files in WSL unbuntu home directory on windows 
Shell :: delete a folder from git 
Shell :: grep second line 
Shell :: github setup local 
Shell :: How do I check out a remote Git branch? 
Shell :: merge pdf in linux 
Shell :: error: insufficient permission for adding an object to repository database .git/objects fatal: failed to write object fatal: unpack-objects failed 
Shell :: git pull branch you are not on 
Shell :: skip ci gitlab 
Shell :: helm install with values file 
Shell :: how to remove a vm in proxmox from terminal 
Shell :: aws cli parse secretstring 
Shell :: git push 
Shell :: create dektop file in ubuntu 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =