Sort .bash_history content alphabetically
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I'm using HISTIGNORE
to ignore the most used commands and HISTCONTROL=ignoreboth:erasedups
to remove duplicates.
Is there a way to periodically sort the contents of the .bash_history
in alphabetical order?
bash cron
add a comment |Â
up vote
0
down vote
favorite
I'm using HISTIGNORE
to ignore the most used commands and HISTCONTROL=ignoreboth:erasedups
to remove duplicates.
Is there a way to periodically sort the contents of the .bash_history
in alphabetical order?
bash cron
Please define âÂÂperiodicallyâÂÂ, and where would you like to store the output; once sorted.
â maulinglawns
Aug 23 at 17:48
like once a week or something ... in => ~/.bash_history
â Ash
Aug 23 at 17:54
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm using HISTIGNORE
to ignore the most used commands and HISTCONTROL=ignoreboth:erasedups
to remove duplicates.
Is there a way to periodically sort the contents of the .bash_history
in alphabetical order?
bash cron
I'm using HISTIGNORE
to ignore the most used commands and HISTCONTROL=ignoreboth:erasedups
to remove duplicates.
Is there a way to periodically sort the contents of the .bash_history
in alphabetical order?
bash cron
bash cron
edited Aug 26 at 18:28
agc
4,1751935
4,1751935
asked Aug 23 at 17:35
Ash
1064
1064
Please define âÂÂperiodicallyâÂÂ, and where would you like to store the output; once sorted.
â maulinglawns
Aug 23 at 17:48
like once a week or something ... in => ~/.bash_history
â Ash
Aug 23 at 17:54
add a comment |Â
Please define âÂÂperiodicallyâÂÂ, and where would you like to store the output; once sorted.
â maulinglawns
Aug 23 at 17:48
like once a week or something ... in => ~/.bash_history
â Ash
Aug 23 at 17:54
Please define âÂÂperiodicallyâÂÂ, and where would you like to store the output; once sorted.
â maulinglawns
Aug 23 at 17:48
Please define âÂÂperiodicallyâÂÂ, and where would you like to store the output; once sorted.
â maulinglawns
Aug 23 at 17:48
like once a week or something ... in => ~/.bash_history
â Ash
Aug 23 at 17:54
like once a week or something ... in => ~/.bash_history
â Ash
Aug 23 at 17:54
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
To see a sorted history without changing it, do:
history | sort -k2
To sort the history file, do:
sort -o ~/.bash_history ~/.bash_history
Then log out of
bash
by typingexit
, and log back in. The new
terminal instance will have an alphabetically sorted history.For the most cautious possible way to sort the history file, first
exit
all
running instances ofbash
, (for the current user anyway), then do:sort -o ~/.bash_history ~/.bash_history
Note: Users generally have no bad results from editing ~/.bash_history while still logged in. But it's fairly certain that exiting all running instance of
bash
is as safe or safer.
This answer would be better with acron
job method as well, but I'm undecided on how to handle systems where terminals are left open for long periods of time. Maybe the job could remind them to log out and log back in, but suppose that's not convenient. Better still would be to have a method that doesn't require andexit
at all.
â agc
Aug 26 at 17:05
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
To see a sorted history without changing it, do:
history | sort -k2
To sort the history file, do:
sort -o ~/.bash_history ~/.bash_history
Then log out of
bash
by typingexit
, and log back in. The new
terminal instance will have an alphabetically sorted history.For the most cautious possible way to sort the history file, first
exit
all
running instances ofbash
, (for the current user anyway), then do:sort -o ~/.bash_history ~/.bash_history
Note: Users generally have no bad results from editing ~/.bash_history while still logged in. But it's fairly certain that exiting all running instance of
bash
is as safe or safer.
This answer would be better with acron
job method as well, but I'm undecided on how to handle systems where terminals are left open for long periods of time. Maybe the job could remind them to log out and log back in, but suppose that's not convenient. Better still would be to have a method that doesn't require andexit
at all.
â agc
Aug 26 at 17:05
add a comment |Â
up vote
2
down vote
accepted
To see a sorted history without changing it, do:
history | sort -k2
To sort the history file, do:
sort -o ~/.bash_history ~/.bash_history
Then log out of
bash
by typingexit
, and log back in. The new
terminal instance will have an alphabetically sorted history.For the most cautious possible way to sort the history file, first
exit
all
running instances ofbash
, (for the current user anyway), then do:sort -o ~/.bash_history ~/.bash_history
Note: Users generally have no bad results from editing ~/.bash_history while still logged in. But it's fairly certain that exiting all running instance of
bash
is as safe or safer.
This answer would be better with acron
job method as well, but I'm undecided on how to handle systems where terminals are left open for long periods of time. Maybe the job could remind them to log out and log back in, but suppose that's not convenient. Better still would be to have a method that doesn't require andexit
at all.
â agc
Aug 26 at 17:05
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
To see a sorted history without changing it, do:
history | sort -k2
To sort the history file, do:
sort -o ~/.bash_history ~/.bash_history
Then log out of
bash
by typingexit
, and log back in. The new
terminal instance will have an alphabetically sorted history.For the most cautious possible way to sort the history file, first
exit
all
running instances ofbash
, (for the current user anyway), then do:sort -o ~/.bash_history ~/.bash_history
Note: Users generally have no bad results from editing ~/.bash_history while still logged in. But it's fairly certain that exiting all running instance of
bash
is as safe or safer.
To see a sorted history without changing it, do:
history | sort -k2
To sort the history file, do:
sort -o ~/.bash_history ~/.bash_history
Then log out of
bash
by typingexit
, and log back in. The new
terminal instance will have an alphabetically sorted history.For the most cautious possible way to sort the history file, first
exit
all
running instances ofbash
, (for the current user anyway), then do:sort -o ~/.bash_history ~/.bash_history
Note: Users generally have no bad results from editing ~/.bash_history while still logged in. But it's fairly certain that exiting all running instance of
bash
is as safe or safer.
edited Aug 26 at 17:00
answered Aug 23 at 17:51
agc
4,1751935
4,1751935
This answer would be better with acron
job method as well, but I'm undecided on how to handle systems where terminals are left open for long periods of time. Maybe the job could remind them to log out and log back in, but suppose that's not convenient. Better still would be to have a method that doesn't require andexit
at all.
â agc
Aug 26 at 17:05
add a comment |Â
This answer would be better with acron
job method as well, but I'm undecided on how to handle systems where terminals are left open for long periods of time. Maybe the job could remind them to log out and log back in, but suppose that's not convenient. Better still would be to have a method that doesn't require andexit
at all.
â agc
Aug 26 at 17:05
This answer would be better with a
cron
job method as well, but I'm undecided on how to handle systems where terminals are left open for long periods of time. Maybe the job could remind them to log out and log back in, but suppose that's not convenient. Better still would be to have a method that doesn't require and exit
at all.â agc
Aug 26 at 17:05
This answer would be better with a
cron
job method as well, but I'm undecided on how to handle systems where terminals are left open for long periods of time. Maybe the job could remind them to log out and log back in, but suppose that's not convenient. Better still would be to have a method that doesn't require and exit
at all.â agc
Aug 26 at 17:05
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%2f464462%2fsort-bash-history-content-alphabetically%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
Please define âÂÂperiodicallyâÂÂ, and where would you like to store the output; once sorted.
â maulinglawns
Aug 23 at 17:48
like once a week or something ... in => ~/.bash_history
â Ash
Aug 23 at 17:54