I'm very new to bash myself, but I've been trying to make little scripts to make some things more efficient.
Bash has a few ways to do loops, including a for loop. Here's the basic thing of it as it applies to your script:
#!/bin/bash func_name () { for file in $@; do echo $file done }
$@ is a special reference to ALL arguments passed to the function.
So if we run this:
func_name this.txt that.md and.html the.css other.yml
It would print each file name on a newline. The arguments need to be space separated.
I think from the above you could adapt it to your needs.
Someone may come and offer a different thing. My knowledge of bash is a bit limited.
Thanks Dan! I'll try that out :)
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I'm very new to bash myself, but I've been trying to make little scripts to make some things more efficient.
Bash has a few ways to do loops, including a for loop. Here's the basic thing of it as it applies to your script:
$@ is a special reference to ALL arguments passed to the function.
So if we run this:
It would print each file name on a newline. The arguments need to be space separated.
I think from the above you could adapt it to your needs.
Someone may come and offer a different thing. My knowledge of bash is a bit limited.
Thanks Dan! I'll try that out :)