[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: bash array



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sun, Jan 14, 2018 at 03:46:06PM +0300, Gokan Atmaca wrote:
> Hello
> 
> I have the user list and the password list. I shot them with BASH. I
> want to give passwords to the usernames in these separate files in
> order.
> 
> File names:
> Users.list
> Passwords.list
> 
> In a loop, I have to not throw them into users of these passwords. I
> did this for it, but it did not work.
> 
> #!bin/bash
> passwords = $ (cat passwords.list)
> for i in $ (cat passwordlist); do my program $ i $passwords; done

Too little context; what exactly doesn't work?

I'd suggest going in little chunks. First try:

  for i in $(cat passwords.list) ; do echo "<$i>" ; done

Does that do what you want?

Unrelated question: why are you doing in your first line

  passwords=$(cat passwords.list)

when in the second line you're doing $(cat passwordlist) anyway?
And shouldn't the second line be $(cat passwords.list?

(NOTE: to assign a shell variable, *no* space before the '='; this
won't work: the shell will read first 'passwords' then <space> and
try to interpret passwords as a command; but this first line seems
superfluous anyway).

> How do I make an Array? Or how can I solve it?

I don't think you need an array for what you are trying. But it
would make sense to get the shell basics straight, first.

Come back with more questions!

Cheers
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlpbY1cACgkQBcgs9XrR2kbYKACfZp0o9RthqaaibDo3Agva/UVz
47gAnjnzfrc7U8m5oUIKqtf6Hd9EufCd
=M0N3
-----END PGP SIGNATURE-----


Reply to: