[Bash] Print out how many number of arguments and arguments Posted by Computer Newbie on 凌晨2:06 in bash script / No comments Bash Script : args=("$@") Number=("$#") echo $# arguments passed for i in $(seq 0 1 $Number) do echo ${args[$i]} done Result : Happy@Happy-laptop:~/Desktop$ bash test123.sh 1 2 3 4 5 6 7 8 8 arguments passed 1 2 3 4 5 6 7 8 Reference : In Bash, how do you access command line arguments inside a function? Bash For Loop Examples Share This: Facebook Twitter Google+ Stumble Digg 以電子郵件傳送這篇文章BlogThis!分享至 X分享至 Facebook Related Posts:[Bash] Execute script after login 1. Put command into /etc/profile After reboot and login will see the effort. Reference: 1. How do you run a script on login in *nix? 2. The Bash… Read More[lighttpd][Samba][Embedded System][bash script] Enable lighttpd server && Enable samba#!/bin/bash do_command ProvSWT #open switch ifconfig lan0 0.0.0.0 ifconfig eth0 192.168.100.1 /fss/gw/sbin/lighttpd -D -f /fss/gw/etc/lighttpd.con… Read More[Bash][function] Passing parameters to a bash function #!/bin/sh foo 1 # this will fail because foo has not been declared yet. foo() { echo "Parameter #1 is $1" } foo 2 # this wil… Read More[bash script] ifconfig 192.168.100.20#!/bin/bash sudo ifconfig eth1 192.168.100.20 netmask 255.255.255.0 ifconfig … Read More[ArchLinxu] Move /home to another folder 1. mv /home/happy /data/ 2. Execute the script after reboot [Unit] Description=My script [Service] ExecStart=/usr/bin/ln -sv /data/happy/ /home/ … Read More
0 意見:
張貼留言