Bash script copy file to user's (wildcard) home dir

Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
I need to copy /root/nbu/file1.sh to every user's home directory if user's id is even number.
Trying to execute following script:
#!/bin/bash
cat /etc/passwd | while read LINE
do
username=$(awk -v var="$LINE" -F: '
if ($3 % 2 == 0)
print $1
')
cp /root/nbu/file1.sh ~"$username"
done
And it does nothing. If I echo cp /root/nbu/file1.sh ~"$username" command and execute it directly in the script, it works.
I guess the problem is that ~ gets expanded in the bash script, but can't figure out how to solve this problem.
Thank you in advance.
shell-script wildcards cp tilde
add a comment |Â
up vote
2
down vote
favorite
I need to copy /root/nbu/file1.sh to every user's home directory if user's id is even number.
Trying to execute following script:
#!/bin/bash
cat /etc/passwd | while read LINE
do
username=$(awk -v var="$LINE" -F: '
if ($3 % 2 == 0)
print $1
')
cp /root/nbu/file1.sh ~"$username"
done
And it does nothing. If I echo cp /root/nbu/file1.sh ~"$username" command and execute it directly in the script, it works.
I guess the problem is that ~ gets expanded in the bash script, but can't figure out how to solve this problem.
Thank you in advance.
shell-script wildcards cp tilde
1
Just a note, ~ is tilde, and $username is a variable; there are no "wildcards" present here. ... Unless one shows up to answer :)
â Jeff Schaller
Mar 7 at 17:52
Relating only: unix.stackexchange.com/questions/270274/â¦
â Jeff Schaller
Mar 7 at 17:56
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I need to copy /root/nbu/file1.sh to every user's home directory if user's id is even number.
Trying to execute following script:
#!/bin/bash
cat /etc/passwd | while read LINE
do
username=$(awk -v var="$LINE" -F: '
if ($3 % 2 == 0)
print $1
')
cp /root/nbu/file1.sh ~"$username"
done
And it does nothing. If I echo cp /root/nbu/file1.sh ~"$username" command and execute it directly in the script, it works.
I guess the problem is that ~ gets expanded in the bash script, but can't figure out how to solve this problem.
Thank you in advance.
shell-script wildcards cp tilde
I need to copy /root/nbu/file1.sh to every user's home directory if user's id is even number.
Trying to execute following script:
#!/bin/bash
cat /etc/passwd | while read LINE
do
username=$(awk -v var="$LINE" -F: '
if ($3 % 2 == 0)
print $1
')
cp /root/nbu/file1.sh ~"$username"
done
And it does nothing. If I echo cp /root/nbu/file1.sh ~"$username" command and execute it directly in the script, it works.
I guess the problem is that ~ gets expanded in the bash script, but can't figure out how to solve this problem.
Thank you in advance.
shell-script wildcards cp tilde
edited Mar 7 at 17:58
ilkkachu
49.2k672136
49.2k672136
asked Mar 7 at 17:42
Ignas Poà ¡ka
132
132
1
Just a note, ~ is tilde, and $username is a variable; there are no "wildcards" present here. ... Unless one shows up to answer :)
â Jeff Schaller
Mar 7 at 17:52
Relating only: unix.stackexchange.com/questions/270274/â¦
â Jeff Schaller
Mar 7 at 17:56
add a comment |Â
1
Just a note, ~ is tilde, and $username is a variable; there are no "wildcards" present here. ... Unless one shows up to answer :)
â Jeff Schaller
Mar 7 at 17:52
Relating only: unix.stackexchange.com/questions/270274/â¦
â Jeff Schaller
Mar 7 at 17:56
1
1
Just a note, ~ is tilde, and $username is a variable; there are no "wildcards" present here. ... Unless one shows up to answer :)
â Jeff Schaller
Mar 7 at 17:52
Just a note, ~ is tilde, and $username is a variable; there are no "wildcards" present here. ... Unless one shows up to answer :)
â Jeff Schaller
Mar 7 at 17:52
Relating only: unix.stackexchange.com/questions/270274/â¦
â Jeff Schaller
Mar 7 at 17:56
Relating only: unix.stackexchange.com/questions/270274/â¦
â Jeff Schaller
Mar 7 at 17:56
add a comment |Â
4 Answers
4
active
oldest
votes
up vote
3
down vote
accepted
You seem on the ball so I won't spoon-feed you a script, but here are some pointers:
You're using
awkincorrectly. Try this instead:awk -F: -v uid_min=$UID_MIN:-1000 '$3%2==0 && $3>uid_min && $3!=65534print $6' /etc/passwdThere's no need for
cat.Use your
awkoutput as the input to yourreadloop, ie.while read USER_HOME_DIR ; do ... ; done < $(awk...). Understand that this will mean that only oneawkprocess needs to be spawned, while your original script spawns a separateawkprocess for each line, so this is much more efficient.Add a check in your
awkprogram to limit it to UID's above 1000, or you will inadvertently perform your copy for many system users.Note that in #1 above, I changed your
$1to$6in order to pull the user's home directory instead of the user's name.I just noticed on my debian machine that there exists a 'nobody' user with UID 65534, so you may need to account for that. I modified the
awkstatement in #1 accordingly.As per user Jeff Schaller's comment, I've modified the
awkprogram to account for a custom minimum UID. The form$UID_MIN:-1000means set the value as 1000 if it would otherwise be null or unset.
1
The Q isn't tagged linux, but if that's the scope, you might useUID_MINrather than hard-coding 1000 in case the local sysadmin adjusted it.
â Jeff Schaller
Mar 7 at 18:12
@JeffSchaller - Thanks. incorporated into the answer.
â user1404316
Mar 7 at 18:32
I should have clarified -- UID_MIN isn't globally set; it's a parameter in /etc/login.defs; sorry!
â Jeff Schaller
Mar 7 at 18:39
Well, at least it was an opportunity teach the shell idiom$FOO:-default. At this point, I'll leave it in for that reason, and won't further change the answer, on the basis that the person running the script or one-liner will be a sysadmin who will know what the UID_MIN value is.
â user1404316
Mar 7 at 18:46
add a comment |Â
up vote
7
down vote
The tilde expansion doesn't work if the username part is quoted:
$ echo ~root ~"root"
/root ~root
(and it happens before variable expansion anyway.)
But since you're already reading passwd in the shell, why not just do it the full way:
#!/bin/bash
getent passwd | while IFS=: read -r user pass uid gid gecos home shell; do
if (( uid % 2 == 0 )); then
echo "uid $uid of user '$user' is even and their home is '$home'";
fi;
done
If your system has getent, it's probably better to use it, rather than /etc/passwd directly.
On the other hand, since you don't really seem to need the username for anything, you could just have your awk script output the directory ($6) instead.
add a comment |Â
up vote
6
down vote
That's because tilde expansion happens before variable expansions:
The order of expansions is: brace expansion; tilde expansion, parameter and variable expansion, arithmetic expansion, and command substitution (done in a left-to-right fashion); word splitting; and filename expansion.
echoing the result looks correct, and works if you re-evaluate it, but for a script, you'll need to do it differently. Perhaps:
# ...
homedir=$(getent passwd "$username" | cut -d: -f6)
cp /root/nbu/file1.sh "$homedir"
# ...
add a comment |Â
up vote
1
down vote
I think I can do it in a one-liner. Check this out:
eval $(awk -v source="/root/nbu/file1.sh" -v uid_min=$UID_MIN:-1000 -F: '$3%2==0 && $3>uid_min && $3!=65534printf "cp %s %s ;", source, $6 ' /etc/passwd)
For readability:
eval $(
awk
-v source="/root/nbu/file1.sh"
-v uid_min=$UID_MIN:-1000
-F: '
$3%2==0 && $3>uid_min && $3!=65534
printf "cp %s %s ;", source, $6
' /etc/passwd
)
1
I would usesource <( awk '...' )instead of eval.
â glenn jackman
Mar 7 at 19:17
add a comment |Â
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
You seem on the ball so I won't spoon-feed you a script, but here are some pointers:
You're using
awkincorrectly. Try this instead:awk -F: -v uid_min=$UID_MIN:-1000 '$3%2==0 && $3>uid_min && $3!=65534print $6' /etc/passwdThere's no need for
cat.Use your
awkoutput as the input to yourreadloop, ie.while read USER_HOME_DIR ; do ... ; done < $(awk...). Understand that this will mean that only oneawkprocess needs to be spawned, while your original script spawns a separateawkprocess for each line, so this is much more efficient.Add a check in your
awkprogram to limit it to UID's above 1000, or you will inadvertently perform your copy for many system users.Note that in #1 above, I changed your
$1to$6in order to pull the user's home directory instead of the user's name.I just noticed on my debian machine that there exists a 'nobody' user with UID 65534, so you may need to account for that. I modified the
awkstatement in #1 accordingly.As per user Jeff Schaller's comment, I've modified the
awkprogram to account for a custom minimum UID. The form$UID_MIN:-1000means set the value as 1000 if it would otherwise be null or unset.
1
The Q isn't tagged linux, but if that's the scope, you might useUID_MINrather than hard-coding 1000 in case the local sysadmin adjusted it.
â Jeff Schaller
Mar 7 at 18:12
@JeffSchaller - Thanks. incorporated into the answer.
â user1404316
Mar 7 at 18:32
I should have clarified -- UID_MIN isn't globally set; it's a parameter in /etc/login.defs; sorry!
â Jeff Schaller
Mar 7 at 18:39
Well, at least it was an opportunity teach the shell idiom$FOO:-default. At this point, I'll leave it in for that reason, and won't further change the answer, on the basis that the person running the script or one-liner will be a sysadmin who will know what the UID_MIN value is.
â user1404316
Mar 7 at 18:46
add a comment |Â
up vote
3
down vote
accepted
You seem on the ball so I won't spoon-feed you a script, but here are some pointers:
You're using
awkincorrectly. Try this instead:awk -F: -v uid_min=$UID_MIN:-1000 '$3%2==0 && $3>uid_min && $3!=65534print $6' /etc/passwdThere's no need for
cat.Use your
awkoutput as the input to yourreadloop, ie.while read USER_HOME_DIR ; do ... ; done < $(awk...). Understand that this will mean that only oneawkprocess needs to be spawned, while your original script spawns a separateawkprocess for each line, so this is much more efficient.Add a check in your
awkprogram to limit it to UID's above 1000, or you will inadvertently perform your copy for many system users.Note that in #1 above, I changed your
$1to$6in order to pull the user's home directory instead of the user's name.I just noticed on my debian machine that there exists a 'nobody' user with UID 65534, so you may need to account for that. I modified the
awkstatement in #1 accordingly.As per user Jeff Schaller's comment, I've modified the
awkprogram to account for a custom minimum UID. The form$UID_MIN:-1000means set the value as 1000 if it would otherwise be null or unset.
1
The Q isn't tagged linux, but if that's the scope, you might useUID_MINrather than hard-coding 1000 in case the local sysadmin adjusted it.
â Jeff Schaller
Mar 7 at 18:12
@JeffSchaller - Thanks. incorporated into the answer.
â user1404316
Mar 7 at 18:32
I should have clarified -- UID_MIN isn't globally set; it's a parameter in /etc/login.defs; sorry!
â Jeff Schaller
Mar 7 at 18:39
Well, at least it was an opportunity teach the shell idiom$FOO:-default. At this point, I'll leave it in for that reason, and won't further change the answer, on the basis that the person running the script or one-liner will be a sysadmin who will know what the UID_MIN value is.
â user1404316
Mar 7 at 18:46
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
You seem on the ball so I won't spoon-feed you a script, but here are some pointers:
You're using
awkincorrectly. Try this instead:awk -F: -v uid_min=$UID_MIN:-1000 '$3%2==0 && $3>uid_min && $3!=65534print $6' /etc/passwdThere's no need for
cat.Use your
awkoutput as the input to yourreadloop, ie.while read USER_HOME_DIR ; do ... ; done < $(awk...). Understand that this will mean that only oneawkprocess needs to be spawned, while your original script spawns a separateawkprocess for each line, so this is much more efficient.Add a check in your
awkprogram to limit it to UID's above 1000, or you will inadvertently perform your copy for many system users.Note that in #1 above, I changed your
$1to$6in order to pull the user's home directory instead of the user's name.I just noticed on my debian machine that there exists a 'nobody' user with UID 65534, so you may need to account for that. I modified the
awkstatement in #1 accordingly.As per user Jeff Schaller's comment, I've modified the
awkprogram to account for a custom minimum UID. The form$UID_MIN:-1000means set the value as 1000 if it would otherwise be null or unset.
You seem on the ball so I won't spoon-feed you a script, but here are some pointers:
You're using
awkincorrectly. Try this instead:awk -F: -v uid_min=$UID_MIN:-1000 '$3%2==0 && $3>uid_min && $3!=65534print $6' /etc/passwdThere's no need for
cat.Use your
awkoutput as the input to yourreadloop, ie.while read USER_HOME_DIR ; do ... ; done < $(awk...). Understand that this will mean that only oneawkprocess needs to be spawned, while your original script spawns a separateawkprocess for each line, so this is much more efficient.Add a check in your
awkprogram to limit it to UID's above 1000, or you will inadvertently perform your copy for many system users.Note that in #1 above, I changed your
$1to$6in order to pull the user's home directory instead of the user's name.I just noticed on my debian machine that there exists a 'nobody' user with UID 65534, so you may need to account for that. I modified the
awkstatement in #1 accordingly.As per user Jeff Schaller's comment, I've modified the
awkprogram to account for a custom minimum UID. The form$UID_MIN:-1000means set the value as 1000 if it would otherwise be null or unset.
edited Mar 7 at 21:39
answered Mar 7 at 18:01
user1404316
2,314520
2,314520
1
The Q isn't tagged linux, but if that's the scope, you might useUID_MINrather than hard-coding 1000 in case the local sysadmin adjusted it.
â Jeff Schaller
Mar 7 at 18:12
@JeffSchaller - Thanks. incorporated into the answer.
â user1404316
Mar 7 at 18:32
I should have clarified -- UID_MIN isn't globally set; it's a parameter in /etc/login.defs; sorry!
â Jeff Schaller
Mar 7 at 18:39
Well, at least it was an opportunity teach the shell idiom$FOO:-default. At this point, I'll leave it in for that reason, and won't further change the answer, on the basis that the person running the script or one-liner will be a sysadmin who will know what the UID_MIN value is.
â user1404316
Mar 7 at 18:46
add a comment |Â
1
The Q isn't tagged linux, but if that's the scope, you might useUID_MINrather than hard-coding 1000 in case the local sysadmin adjusted it.
â Jeff Schaller
Mar 7 at 18:12
@JeffSchaller - Thanks. incorporated into the answer.
â user1404316
Mar 7 at 18:32
I should have clarified -- UID_MIN isn't globally set; it's a parameter in /etc/login.defs; sorry!
â Jeff Schaller
Mar 7 at 18:39
Well, at least it was an opportunity teach the shell idiom$FOO:-default. At this point, I'll leave it in for that reason, and won't further change the answer, on the basis that the person running the script or one-liner will be a sysadmin who will know what the UID_MIN value is.
â user1404316
Mar 7 at 18:46
1
1
The Q isn't tagged linux, but if that's the scope, you might use
UID_MIN rather than hard-coding 1000 in case the local sysadmin adjusted it.â Jeff Schaller
Mar 7 at 18:12
The Q isn't tagged linux, but if that's the scope, you might use
UID_MIN rather than hard-coding 1000 in case the local sysadmin adjusted it.â Jeff Schaller
Mar 7 at 18:12
@JeffSchaller - Thanks. incorporated into the answer.
â user1404316
Mar 7 at 18:32
@JeffSchaller - Thanks. incorporated into the answer.
â user1404316
Mar 7 at 18:32
I should have clarified -- UID_MIN isn't globally set; it's a parameter in /etc/login.defs; sorry!
â Jeff Schaller
Mar 7 at 18:39
I should have clarified -- UID_MIN isn't globally set; it's a parameter in /etc/login.defs; sorry!
â Jeff Schaller
Mar 7 at 18:39
Well, at least it was an opportunity teach the shell idiom
$FOO:-default. At this point, I'll leave it in for that reason, and won't further change the answer, on the basis that the person running the script or one-liner will be a sysadmin who will know what the UID_MIN value is.â user1404316
Mar 7 at 18:46
Well, at least it was an opportunity teach the shell idiom
$FOO:-default. At this point, I'll leave it in for that reason, and won't further change the answer, on the basis that the person running the script or one-liner will be a sysadmin who will know what the UID_MIN value is.â user1404316
Mar 7 at 18:46
add a comment |Â
up vote
7
down vote
The tilde expansion doesn't work if the username part is quoted:
$ echo ~root ~"root"
/root ~root
(and it happens before variable expansion anyway.)
But since you're already reading passwd in the shell, why not just do it the full way:
#!/bin/bash
getent passwd | while IFS=: read -r user pass uid gid gecos home shell; do
if (( uid % 2 == 0 )); then
echo "uid $uid of user '$user' is even and their home is '$home'";
fi;
done
If your system has getent, it's probably better to use it, rather than /etc/passwd directly.
On the other hand, since you don't really seem to need the username for anything, you could just have your awk script output the directory ($6) instead.
add a comment |Â
up vote
7
down vote
The tilde expansion doesn't work if the username part is quoted:
$ echo ~root ~"root"
/root ~root
(and it happens before variable expansion anyway.)
But since you're already reading passwd in the shell, why not just do it the full way:
#!/bin/bash
getent passwd | while IFS=: read -r user pass uid gid gecos home shell; do
if (( uid % 2 == 0 )); then
echo "uid $uid of user '$user' is even and their home is '$home'";
fi;
done
If your system has getent, it's probably better to use it, rather than /etc/passwd directly.
On the other hand, since you don't really seem to need the username for anything, you could just have your awk script output the directory ($6) instead.
add a comment |Â
up vote
7
down vote
up vote
7
down vote
The tilde expansion doesn't work if the username part is quoted:
$ echo ~root ~"root"
/root ~root
(and it happens before variable expansion anyway.)
But since you're already reading passwd in the shell, why not just do it the full way:
#!/bin/bash
getent passwd | while IFS=: read -r user pass uid gid gecos home shell; do
if (( uid % 2 == 0 )); then
echo "uid $uid of user '$user' is even and their home is '$home'";
fi;
done
If your system has getent, it's probably better to use it, rather than /etc/passwd directly.
On the other hand, since you don't really seem to need the username for anything, you could just have your awk script output the directory ($6) instead.
The tilde expansion doesn't work if the username part is quoted:
$ echo ~root ~"root"
/root ~root
(and it happens before variable expansion anyway.)
But since you're already reading passwd in the shell, why not just do it the full way:
#!/bin/bash
getent passwd | while IFS=: read -r user pass uid gid gecos home shell; do
if (( uid % 2 == 0 )); then
echo "uid $uid of user '$user' is even and their home is '$home'";
fi;
done
If your system has getent, it's probably better to use it, rather than /etc/passwd directly.
On the other hand, since you don't really seem to need the username for anything, you could just have your awk script output the directory ($6) instead.
answered Mar 7 at 17:55
ilkkachu
49.2k672136
49.2k672136
add a comment |Â
add a comment |Â
up vote
6
down vote
That's because tilde expansion happens before variable expansions:
The order of expansions is: brace expansion; tilde expansion, parameter and variable expansion, arithmetic expansion, and command substitution (done in a left-to-right fashion); word splitting; and filename expansion.
echoing the result looks correct, and works if you re-evaluate it, but for a script, you'll need to do it differently. Perhaps:
# ...
homedir=$(getent passwd "$username" | cut -d: -f6)
cp /root/nbu/file1.sh "$homedir"
# ...
add a comment |Â
up vote
6
down vote
That's because tilde expansion happens before variable expansions:
The order of expansions is: brace expansion; tilde expansion, parameter and variable expansion, arithmetic expansion, and command substitution (done in a left-to-right fashion); word splitting; and filename expansion.
echoing the result looks correct, and works if you re-evaluate it, but for a script, you'll need to do it differently. Perhaps:
# ...
homedir=$(getent passwd "$username" | cut -d: -f6)
cp /root/nbu/file1.sh "$homedir"
# ...
add a comment |Â
up vote
6
down vote
up vote
6
down vote
That's because tilde expansion happens before variable expansions:
The order of expansions is: brace expansion; tilde expansion, parameter and variable expansion, arithmetic expansion, and command substitution (done in a left-to-right fashion); word splitting; and filename expansion.
echoing the result looks correct, and works if you re-evaluate it, but for a script, you'll need to do it differently. Perhaps:
# ...
homedir=$(getent passwd "$username" | cut -d: -f6)
cp /root/nbu/file1.sh "$homedir"
# ...
That's because tilde expansion happens before variable expansions:
The order of expansions is: brace expansion; tilde expansion, parameter and variable expansion, arithmetic expansion, and command substitution (done in a left-to-right fashion); word splitting; and filename expansion.
echoing the result looks correct, and works if you re-evaluate it, but for a script, you'll need to do it differently. Perhaps:
# ...
homedir=$(getent passwd "$username" | cut -d: -f6)
cp /root/nbu/file1.sh "$homedir"
# ...
answered Mar 7 at 17:51
Jeff Schaller
31.2k846105
31.2k846105
add a comment |Â
add a comment |Â
up vote
1
down vote
I think I can do it in a one-liner. Check this out:
eval $(awk -v source="/root/nbu/file1.sh" -v uid_min=$UID_MIN:-1000 -F: '$3%2==0 && $3>uid_min && $3!=65534printf "cp %s %s ;", source, $6 ' /etc/passwd)
For readability:
eval $(
awk
-v source="/root/nbu/file1.sh"
-v uid_min=$UID_MIN:-1000
-F: '
$3%2==0 && $3>uid_min && $3!=65534
printf "cp %s %s ;", source, $6
' /etc/passwd
)
1
I would usesource <( awk '...' )instead of eval.
â glenn jackman
Mar 7 at 19:17
add a comment |Â
up vote
1
down vote
I think I can do it in a one-liner. Check this out:
eval $(awk -v source="/root/nbu/file1.sh" -v uid_min=$UID_MIN:-1000 -F: '$3%2==0 && $3>uid_min && $3!=65534printf "cp %s %s ;", source, $6 ' /etc/passwd)
For readability:
eval $(
awk
-v source="/root/nbu/file1.sh"
-v uid_min=$UID_MIN:-1000
-F: '
$3%2==0 && $3>uid_min && $3!=65534
printf "cp %s %s ;", source, $6
' /etc/passwd
)
1
I would usesource <( awk '...' )instead of eval.
â glenn jackman
Mar 7 at 19:17
add a comment |Â
up vote
1
down vote
up vote
1
down vote
I think I can do it in a one-liner. Check this out:
eval $(awk -v source="/root/nbu/file1.sh" -v uid_min=$UID_MIN:-1000 -F: '$3%2==0 && $3>uid_min && $3!=65534printf "cp %s %s ;", source, $6 ' /etc/passwd)
For readability:
eval $(
awk
-v source="/root/nbu/file1.sh"
-v uid_min=$UID_MIN:-1000
-F: '
$3%2==0 && $3>uid_min && $3!=65534
printf "cp %s %s ;", source, $6
' /etc/passwd
)
I think I can do it in a one-liner. Check this out:
eval $(awk -v source="/root/nbu/file1.sh" -v uid_min=$UID_MIN:-1000 -F: '$3%2==0 && $3>uid_min && $3!=65534printf "cp %s %s ;", source, $6 ' /etc/passwd)
For readability:
eval $(
awk
-v source="/root/nbu/file1.sh"
-v uid_min=$UID_MIN:-1000
-F: '
$3%2==0 && $3>uid_min && $3!=65534
printf "cp %s %s ;", source, $6
' /etc/passwd
)
edited Mar 7 at 19:27
answered Mar 7 at 18:24
user1404316
2,314520
2,314520
1
I would usesource <( awk '...' )instead of eval.
â glenn jackman
Mar 7 at 19:17
add a comment |Â
1
I would usesource <( awk '...' )instead of eval.
â glenn jackman
Mar 7 at 19:17
1
1
I would use
source <( awk '...' ) instead of eval.â glenn jackman
Mar 7 at 19:17
I would use
source <( awk '...' ) instead of eval.â glenn jackman
Mar 7 at 19:17
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f428811%2fbash-script-copy-file-to-users-wildcard-home-dir%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
Just a note, ~ is tilde, and $username is a variable; there are no "wildcards" present here. ... Unless one shows up to answer :)
â Jeff Schaller
Mar 7 at 17:52
Relating only: unix.stackexchange.com/questions/270274/â¦
â Jeff Schaller
Mar 7 at 17:56