Creating a permanent variableHow to make a permanent variableKeep global variables values piping through functionsHow do I set an environment variable for sudo in MacOS?How to print the values of variables with incremented numbers using a loop in shell script?Cron Bash Script - echo to current terminal instead of /var/spool/mail/rootConditional execution block with || and parentheses problemSeparating variable names from output strings with no whitespaceChange default login shell to /bin/bash for ALL ldap users from LDAP server - not clientVariable Crossover in multiple bash scripts?Using a variable to execute a curl commandCron shell ignores runuser command - why?
Hostile work environment after whistle-blowing on coworker and our boss. What do I do?
How does Loki do this?
How easy is it to start Magic from scratch?
Why Were Madagascar and New Zealand Discovered So Late?
How did Doctor Strange see the winning outcome in Avengers: Infinity War?
Gears on left are inverse to gears on right?
Anatomically Correct Strange Women In Ponds Distributing Swords
Sequence of Tenses: Translating the subjunctive
What can we do to stop prior company from asking us questions?
How to safely derail a train during transit?
Is there a korbon needed for conversion?
Do sorcerers' Subtle Spells require a skill check to be unseen?
Proof of work - lottery approach
How does it work when somebody invests in my business?
How to write papers efficiently when English isn't my first language?
Would a high gravity rocky planet be guaranteed to have an atmosphere?
How did Arya survive the stabbing?
I'm in charge of equipment buying but no one's ever happy with what I choose. How to fix this?
Roman Numeral Treatment of Suspensions
Type int? vs type int
Inappropriate reference requests from Journal reviewers
Class Action - which options I have?
Is a stroke of luck acceptable after a series of unfavorable events?
Is expanding the research of a group into machine learning as a PhD student risky?
Creating a permanent variable
How to make a permanent variableKeep global variables values piping through functionsHow do I set an environment variable for sudo in MacOS?How to print the values of variables with incremented numbers using a loop in shell script?Cron Bash Script - echo to current terminal instead of /var/spool/mail/rootConditional execution block with || and parentheses problemSeparating variable names from output strings with no whitespaceChange default login shell to /bin/bash for ALL ldap users from LDAP server - not clientVariable Crossover in multiple bash scripts?Using a variable to execute a curl commandCron shell ignores runuser command - why?
Is it possible to set "permanent variable" in shell? For example,
when I log in I want to print message "Hello user, this is your xxx log in"
The number of logins would be stored in permanent variable, and each time it would be incremented by script e.g
#!/bin/bash
echo "Hello Mr. This is your $number log in"
$number=$(($number+1))
The next log in would print the incremented variable and increment it again.
How could I set a variable like that?
bash shell shell-script
add a comment |
Is it possible to set "permanent variable" in shell? For example,
when I log in I want to print message "Hello user, this is your xxx log in"
The number of logins would be stored in permanent variable, and each time it would be incremented by script e.g
#!/bin/bash
echo "Hello Mr. This is your $number log in"
$number=$(($number+1))
The next log in would print the incremented variable and increment it again.
How could I set a variable like that?
bash shell shell-script
3
You need to write that number into a file and read from file every time you login, in your .profile or .bashrc or equivalent.
– MelBurslan
Mar 3 '16 at 20:15
2
That's literally what files are for.
– PSkocik
Mar 3 '16 at 20:22
you also have to think about what you consider to be a "login". You can login at the console, or over the network (e.g. via ssh). Most terminal apps can be configured so that each tab can be treated as a login shell. So what you consider to be a login and what (various parts of) the system considers to be a login may be completely different.
– cas
Mar 3 '16 at 21:30
add a comment |
Is it possible to set "permanent variable" in shell? For example,
when I log in I want to print message "Hello user, this is your xxx log in"
The number of logins would be stored in permanent variable, and each time it would be incremented by script e.g
#!/bin/bash
echo "Hello Mr. This is your $number log in"
$number=$(($number+1))
The next log in would print the incremented variable and increment it again.
How could I set a variable like that?
bash shell shell-script
Is it possible to set "permanent variable" in shell? For example,
when I log in I want to print message "Hello user, this is your xxx log in"
The number of logins would be stored in permanent variable, and each time it would be incremented by script e.g
#!/bin/bash
echo "Hello Mr. This is your $number log in"
$number=$(($number+1))
The next log in would print the incremented variable and increment it again.
How could I set a variable like that?
bash shell shell-script
bash shell shell-script
edited Mar 3 '16 at 20:36
Jeff Schaller♦
44k1161142
44k1161142
asked Mar 3 '16 at 20:09
J.ddJ.dd
82
82
3
You need to write that number into a file and read from file every time you login, in your .profile or .bashrc or equivalent.
– MelBurslan
Mar 3 '16 at 20:15
2
That's literally what files are for.
– PSkocik
Mar 3 '16 at 20:22
you also have to think about what you consider to be a "login". You can login at the console, or over the network (e.g. via ssh). Most terminal apps can be configured so that each tab can be treated as a login shell. So what you consider to be a login and what (various parts of) the system considers to be a login may be completely different.
– cas
Mar 3 '16 at 21:30
add a comment |
3
You need to write that number into a file and read from file every time you login, in your .profile or .bashrc or equivalent.
– MelBurslan
Mar 3 '16 at 20:15
2
That's literally what files are for.
– PSkocik
Mar 3 '16 at 20:22
you also have to think about what you consider to be a "login". You can login at the console, or over the network (e.g. via ssh). Most terminal apps can be configured so that each tab can be treated as a login shell. So what you consider to be a login and what (various parts of) the system considers to be a login may be completely different.
– cas
Mar 3 '16 at 21:30
3
3
You need to write that number into a file and read from file every time you login, in your .profile or .bashrc or equivalent.
– MelBurslan
Mar 3 '16 at 20:15
You need to write that number into a file and read from file every time you login, in your .profile or .bashrc or equivalent.
– MelBurslan
Mar 3 '16 at 20:15
2
2
That's literally what files are for.
– PSkocik
Mar 3 '16 at 20:22
That's literally what files are for.
– PSkocik
Mar 3 '16 at 20:22
you also have to think about what you consider to be a "login". You can login at the console, or over the network (e.g. via ssh). Most terminal apps can be configured so that each tab can be treated as a login shell. So what you consider to be a login and what (various parts of) the system considers to be a login may be completely different.
– cas
Mar 3 '16 at 21:30
you also have to think about what you consider to be a "login". You can login at the console, or over the network (e.g. via ssh). Most terminal apps can be configured so that each tab can be treated as a login shell. So what you consider to be a login and what (various parts of) the system considers to be a login may be completely different.
– cas
Mar 3 '16 at 21:30
add a comment |
6 Answers
6
active
oldest
votes
You can't. However, you can use various hacks to do it, for example creating a file in some folder each time a user logs in, or adding a line to some file each time a user logs in. These would be easy to implement, but inefficient in long run. A much more efficient operation would be writing a number to a file, and changing it. You would, however, have to be sure that the file is structured as you want and that the number is where you expect it to be. Since these are hacks, they aren't perfect(malicious user can modify these), but could suffice for your problem.
You can count lines with wc -l
add a comment |
I'd write:
#!/bin/bash
file=$HOME/.login_count
number=$(<"$file")
echo "Hello Mr. This is your $number log in"
echo $((number+1)) > "$file"
Does this properly handle malicious file contents? e.g.7; rm -r /
– wizzwizz4
yesterday
I think it's fine: the contents of thenumber
variable are not evaluated in the echo command (double quotes) and in arithmetic context there will be a syntax error.
– glenn jackman
yesterday
add a comment |
Matthew Rock's answer is nice as are the other ones but like Matthew points out then the user can change these numbers. One way to circumvent that is to use PAM.
I would put the following line in /etc/pam.d/login
session optional pam_exec.so /usr/local/bin/someshellscript.sh
And in /usr/local/bin/someshellscript.sh
you can use variables like $PAM_USER
which gives the username. Then in the shellscript you can access a file that is not writable (and perhaps not readable, depends on what you want) to the users and keep tabs on all the users and how often they have logged in, in that file. I leave the writing of that script as an exercise to the reader ;-)
add a comment |
Here's one possible hack; add the following lines to your $HOME/.bash_profile (since you tagged bash):
NLOGINS=0
printf "Hello Mr. This is your %d log inn" $((NLOGINS + 1))
sed -i 's/^NLOGINS=.*/NLOGINS='$((NLOGINS + 1))'/' $HOME/.bash_profile
Each time you log in, you'll get the printed message and then it will self-update the .bash_profile with the new NLOGINS count.
add a comment |
Look at this post https://unix.stackexchange.com/a/350163
Permanent variables using kv-bash
functions:
1) Download kv-bash
file from github:
git clone https://github.com/damphat/kv-bash.git
cp -ar ./kv-bash/kv-bash /usr/local
chmod +x /usr/local/kv-bash
# Put this line in .bash_profile (optional)
source kv-bash
2) Try
#let try create/modify/delete variable
kvset myEmail john@example.com
kvset myCommand "Very Long Long Long String"
#read the varible
kvget myEmail
#you can also use in another script with $(kvget myEmail)
echo $(kvget myEmail)
#delete variable
kvdel myEmail
add a comment |
With zsh
, you can use the $mapfile
special associative array that gives you access to the content of a file as a variable (beware of concurrent access).
#! /bin/zsh -
zmodload zsh/mapfile
echo "Hello Mr. This is your $((++mapfile[$HOME/.number]))th log in"
fish
has so-called Universal variables whose content is stored in files in your ~/.config
and to which fish
serializes access via some IPC mechanism.
#! /bin/fish -
set -U number (math 0$number+1)
echo Hello Mr. This is your $numberth log in
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f267460%2fcreating-a-permanent-variable%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can't. However, you can use various hacks to do it, for example creating a file in some folder each time a user logs in, or adding a line to some file each time a user logs in. These would be easy to implement, but inefficient in long run. A much more efficient operation would be writing a number to a file, and changing it. You would, however, have to be sure that the file is structured as you want and that the number is where you expect it to be. Since these are hacks, they aren't perfect(malicious user can modify these), but could suffice for your problem.
You can count lines with wc -l
add a comment |
You can't. However, you can use various hacks to do it, for example creating a file in some folder each time a user logs in, or adding a line to some file each time a user logs in. These would be easy to implement, but inefficient in long run. A much more efficient operation would be writing a number to a file, and changing it. You would, however, have to be sure that the file is structured as you want and that the number is where you expect it to be. Since these are hacks, they aren't perfect(malicious user can modify these), but could suffice for your problem.
You can count lines with wc -l
add a comment |
You can't. However, you can use various hacks to do it, for example creating a file in some folder each time a user logs in, or adding a line to some file each time a user logs in. These would be easy to implement, but inefficient in long run. A much more efficient operation would be writing a number to a file, and changing it. You would, however, have to be sure that the file is structured as you want and that the number is where you expect it to be. Since these are hacks, they aren't perfect(malicious user can modify these), but could suffice for your problem.
You can count lines with wc -l
You can't. However, you can use various hacks to do it, for example creating a file in some folder each time a user logs in, or adding a line to some file each time a user logs in. These would be easy to implement, but inefficient in long run. A much more efficient operation would be writing a number to a file, and changing it. You would, however, have to be sure that the file is structured as you want and that the number is where you expect it to be. Since these are hacks, they aren't perfect(malicious user can modify these), but could suffice for your problem.
You can count lines with wc -l
edited Mar 4 '16 at 23:24
answered Mar 3 '16 at 20:14
MatthewRockMatthewRock
4,02331848
4,02331848
add a comment |
add a comment |
I'd write:
#!/bin/bash
file=$HOME/.login_count
number=$(<"$file")
echo "Hello Mr. This is your $number log in"
echo $((number+1)) > "$file"
Does this properly handle malicious file contents? e.g.7; rm -r /
– wizzwizz4
yesterday
I think it's fine: the contents of thenumber
variable are not evaluated in the echo command (double quotes) and in arithmetic context there will be a syntax error.
– glenn jackman
yesterday
add a comment |
I'd write:
#!/bin/bash
file=$HOME/.login_count
number=$(<"$file")
echo "Hello Mr. This is your $number log in"
echo $((number+1)) > "$file"
Does this properly handle malicious file contents? e.g.7; rm -r /
– wizzwizz4
yesterday
I think it's fine: the contents of thenumber
variable are not evaluated in the echo command (double quotes) and in arithmetic context there will be a syntax error.
– glenn jackman
yesterday
add a comment |
I'd write:
#!/bin/bash
file=$HOME/.login_count
number=$(<"$file")
echo "Hello Mr. This is your $number log in"
echo $((number+1)) > "$file"
I'd write:
#!/bin/bash
file=$HOME/.login_count
number=$(<"$file")
echo "Hello Mr. This is your $number log in"
echo $((number+1)) > "$file"
answered Mar 3 '16 at 20:31
glenn jackmanglenn jackman
52.7k573114
52.7k573114
Does this properly handle malicious file contents? e.g.7; rm -r /
– wizzwizz4
yesterday
I think it's fine: the contents of thenumber
variable are not evaluated in the echo command (double quotes) and in arithmetic context there will be a syntax error.
– glenn jackman
yesterday
add a comment |
Does this properly handle malicious file contents? e.g.7; rm -r /
– wizzwizz4
yesterday
I think it's fine: the contents of thenumber
variable are not evaluated in the echo command (double quotes) and in arithmetic context there will be a syntax error.
– glenn jackman
yesterday
Does this properly handle malicious file contents? e.g.
7; rm -r /
– wizzwizz4
yesterday
Does this properly handle malicious file contents? e.g.
7; rm -r /
– wizzwizz4
yesterday
I think it's fine: the contents of the
number
variable are not evaluated in the echo command (double quotes) and in arithmetic context there will be a syntax error.– glenn jackman
yesterday
I think it's fine: the contents of the
number
variable are not evaluated in the echo command (double quotes) and in arithmetic context there will be a syntax error.– glenn jackman
yesterday
add a comment |
Matthew Rock's answer is nice as are the other ones but like Matthew points out then the user can change these numbers. One way to circumvent that is to use PAM.
I would put the following line in /etc/pam.d/login
session optional pam_exec.so /usr/local/bin/someshellscript.sh
And in /usr/local/bin/someshellscript.sh
you can use variables like $PAM_USER
which gives the username. Then in the shellscript you can access a file that is not writable (and perhaps not readable, depends on what you want) to the users and keep tabs on all the users and how often they have logged in, in that file. I leave the writing of that script as an exercise to the reader ;-)
add a comment |
Matthew Rock's answer is nice as are the other ones but like Matthew points out then the user can change these numbers. One way to circumvent that is to use PAM.
I would put the following line in /etc/pam.d/login
session optional pam_exec.so /usr/local/bin/someshellscript.sh
And in /usr/local/bin/someshellscript.sh
you can use variables like $PAM_USER
which gives the username. Then in the shellscript you can access a file that is not writable (and perhaps not readable, depends on what you want) to the users and keep tabs on all the users and how often they have logged in, in that file. I leave the writing of that script as an exercise to the reader ;-)
add a comment |
Matthew Rock's answer is nice as are the other ones but like Matthew points out then the user can change these numbers. One way to circumvent that is to use PAM.
I would put the following line in /etc/pam.d/login
session optional pam_exec.so /usr/local/bin/someshellscript.sh
And in /usr/local/bin/someshellscript.sh
you can use variables like $PAM_USER
which gives the username. Then in the shellscript you can access a file that is not writable (and perhaps not readable, depends on what you want) to the users and keep tabs on all the users and how often they have logged in, in that file. I leave the writing of that script as an exercise to the reader ;-)
Matthew Rock's answer is nice as are the other ones but like Matthew points out then the user can change these numbers. One way to circumvent that is to use PAM.
I would put the following line in /etc/pam.d/login
session optional pam_exec.so /usr/local/bin/someshellscript.sh
And in /usr/local/bin/someshellscript.sh
you can use variables like $PAM_USER
which gives the username. Then in the shellscript you can access a file that is not writable (and perhaps not readable, depends on what you want) to the users and keep tabs on all the users and how often they have logged in, in that file. I leave the writing of that script as an exercise to the reader ;-)
answered Mar 5 '16 at 1:05
ojsojs
656410
656410
add a comment |
add a comment |
Here's one possible hack; add the following lines to your $HOME/.bash_profile (since you tagged bash):
NLOGINS=0
printf "Hello Mr. This is your %d log inn" $((NLOGINS + 1))
sed -i 's/^NLOGINS=.*/NLOGINS='$((NLOGINS + 1))'/' $HOME/.bash_profile
Each time you log in, you'll get the printed message and then it will self-update the .bash_profile with the new NLOGINS count.
add a comment |
Here's one possible hack; add the following lines to your $HOME/.bash_profile (since you tagged bash):
NLOGINS=0
printf "Hello Mr. This is your %d log inn" $((NLOGINS + 1))
sed -i 's/^NLOGINS=.*/NLOGINS='$((NLOGINS + 1))'/' $HOME/.bash_profile
Each time you log in, you'll get the printed message and then it will self-update the .bash_profile with the new NLOGINS count.
add a comment |
Here's one possible hack; add the following lines to your $HOME/.bash_profile (since you tagged bash):
NLOGINS=0
printf "Hello Mr. This is your %d log inn" $((NLOGINS + 1))
sed -i 's/^NLOGINS=.*/NLOGINS='$((NLOGINS + 1))'/' $HOME/.bash_profile
Each time you log in, you'll get the printed message and then it will self-update the .bash_profile with the new NLOGINS count.
Here's one possible hack; add the following lines to your $HOME/.bash_profile (since you tagged bash):
NLOGINS=0
printf "Hello Mr. This is your %d log inn" $((NLOGINS + 1))
sed -i 's/^NLOGINS=.*/NLOGINS='$((NLOGINS + 1))'/' $HOME/.bash_profile
Each time you log in, you'll get the printed message and then it will self-update the .bash_profile with the new NLOGINS count.
answered Mar 3 '16 at 20:29
Jeff Schaller♦Jeff Schaller
44k1161142
44k1161142
add a comment |
add a comment |
Look at this post https://unix.stackexchange.com/a/350163
Permanent variables using kv-bash
functions:
1) Download kv-bash
file from github:
git clone https://github.com/damphat/kv-bash.git
cp -ar ./kv-bash/kv-bash /usr/local
chmod +x /usr/local/kv-bash
# Put this line in .bash_profile (optional)
source kv-bash
2) Try
#let try create/modify/delete variable
kvset myEmail john@example.com
kvset myCommand "Very Long Long Long String"
#read the varible
kvget myEmail
#you can also use in another script with $(kvget myEmail)
echo $(kvget myEmail)
#delete variable
kvdel myEmail
add a comment |
Look at this post https://unix.stackexchange.com/a/350163
Permanent variables using kv-bash
functions:
1) Download kv-bash
file from github:
git clone https://github.com/damphat/kv-bash.git
cp -ar ./kv-bash/kv-bash /usr/local
chmod +x /usr/local/kv-bash
# Put this line in .bash_profile (optional)
source kv-bash
2) Try
#let try create/modify/delete variable
kvset myEmail john@example.com
kvset myCommand "Very Long Long Long String"
#read the varible
kvget myEmail
#you can also use in another script with $(kvget myEmail)
echo $(kvget myEmail)
#delete variable
kvdel myEmail
add a comment |
Look at this post https://unix.stackexchange.com/a/350163
Permanent variables using kv-bash
functions:
1) Download kv-bash
file from github:
git clone https://github.com/damphat/kv-bash.git
cp -ar ./kv-bash/kv-bash /usr/local
chmod +x /usr/local/kv-bash
# Put this line in .bash_profile (optional)
source kv-bash
2) Try
#let try create/modify/delete variable
kvset myEmail john@example.com
kvset myCommand "Very Long Long Long String"
#read the varible
kvget myEmail
#you can also use in another script with $(kvget myEmail)
echo $(kvget myEmail)
#delete variable
kvdel myEmail
Look at this post https://unix.stackexchange.com/a/350163
Permanent variables using kv-bash
functions:
1) Download kv-bash
file from github:
git clone https://github.com/damphat/kv-bash.git
cp -ar ./kv-bash/kv-bash /usr/local
chmod +x /usr/local/kv-bash
# Put this line in .bash_profile (optional)
source kv-bash
2) Try
#let try create/modify/delete variable
kvset myEmail john@example.com
kvset myCommand "Very Long Long Long String"
#read the varible
kvget myEmail
#you can also use in another script with $(kvget myEmail)
echo $(kvget myEmail)
#delete variable
kvdel myEmail
edited Apr 13 '17 at 12:36
Community♦
1
1
answered Mar 9 '17 at 7:25
NizaNiza
1
1
add a comment |
add a comment |
With zsh
, you can use the $mapfile
special associative array that gives you access to the content of a file as a variable (beware of concurrent access).
#! /bin/zsh -
zmodload zsh/mapfile
echo "Hello Mr. This is your $((++mapfile[$HOME/.number]))th log in"
fish
has so-called Universal variables whose content is stored in files in your ~/.config
and to which fish
serializes access via some IPC mechanism.
#! /bin/fish -
set -U number (math 0$number+1)
echo Hello Mr. This is your $numberth log in
add a comment |
With zsh
, you can use the $mapfile
special associative array that gives you access to the content of a file as a variable (beware of concurrent access).
#! /bin/zsh -
zmodload zsh/mapfile
echo "Hello Mr. This is your $((++mapfile[$HOME/.number]))th log in"
fish
has so-called Universal variables whose content is stored in files in your ~/.config
and to which fish
serializes access via some IPC mechanism.
#! /bin/fish -
set -U number (math 0$number+1)
echo Hello Mr. This is your $numberth log in
add a comment |
With zsh
, you can use the $mapfile
special associative array that gives you access to the content of a file as a variable (beware of concurrent access).
#! /bin/zsh -
zmodload zsh/mapfile
echo "Hello Mr. This is your $((++mapfile[$HOME/.number]))th log in"
fish
has so-called Universal variables whose content is stored in files in your ~/.config
and to which fish
serializes access via some IPC mechanism.
#! /bin/fish -
set -U number (math 0$number+1)
echo Hello Mr. This is your $numberth log in
With zsh
, you can use the $mapfile
special associative array that gives you access to the content of a file as a variable (beware of concurrent access).
#! /bin/zsh -
zmodload zsh/mapfile
echo "Hello Mr. This is your $((++mapfile[$HOME/.number]))th log in"
fish
has so-called Universal variables whose content is stored in files in your ~/.config
and to which fish
serializes access via some IPC mechanism.
#! /bin/fish -
set -U number (math 0$number+1)
echo Hello Mr. This is your $numberth log in
edited yesterday
answered Mar 4 '16 at 23:37
Stéphane ChazelasStéphane Chazelas
311k57589946
311k57589946
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f267460%2fcreating-a-permanent-variable%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
-bash, shell, shell-script
3
You need to write that number into a file and read from file every time you login, in your .profile or .bashrc or equivalent.
– MelBurslan
Mar 3 '16 at 20:15
2
That's literally what files are for.
– PSkocik
Mar 3 '16 at 20:22
you also have to think about what you consider to be a "login". You can login at the console, or over the network (e.g. via ssh). Most terminal apps can be configured so that each tab can be treated as a login shell. So what you consider to be a login and what (various parts of) the system considers to be a login may be completely different.
– cas
Mar 3 '16 at 21:30