Saving first n lines of history


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Saving first n lines of history
# 1  
Old 02-12-2019
Saving first n lines of history

Say you want to clear your .bash_history except for the first 25 lines. Try:
Code:
sed -i -e 26,500d .bash_history

I have a some frequently-used routines parked in the first few lines, and they kept getting overwritten by more recent commands.
# 2  
Old 02-12-2019
I'd rather use .profile or other shell init / rc files to revive those 25 most needed commands at each login.
This User Gave Thanks to RudiC For This Post:
# 3  
Old 02-12-2019
in your .bash_profile (or .profile) you could do:
Code:
HISTFILESIZE= 
HISTSIZE=

to make your bash history unlimited; this way they won't be overwritten.
This User Gave Thanks to milhan For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. What is on Your Mind?

The Great History of UNIX (1969-1999) | 30 Years of UNIX History | YouTube Video

I am pleased to announce this new video in 1080 HD for UNIX lovers honoring thirty years of UNIX history spanning from 1969 to 1999 presented in 150 seconds (two and a half minutes) in 1080 HD, celebrating the 50th anniversary of UNIX. The Great History of UNIX (1969-1999) | 30 Years of UNIX... (8 Replies)
Discussion started by: Neo
8 Replies

2. UNIX for Dummies Questions & Answers

History to Another file [local user history , but root access]

Hi all, My need is : 1. To know who , when , which command used. 2. Local user should not delete this information. I mean , with an example , i can say i have a user user1 i need to give all the following permissions to user1, : a. A specific directory other than his home... (1 Reply)
Discussion started by: sriky86
1 Replies

3. UNIX for Dummies Questions & Answers

Help with deleting lines and saving them

I have a directory question where I ask the user which entry he wants to delete... echo "Which entry?" read entry sed '/^'$entry'/d' file This code does in fact delete that particular entry... HOWEVER, when I go to inquire about that same entry, it still populates like it was never... (4 Replies)
Discussion started by: itech4814
4 Replies

4. UNIX for Dummies Questions & Answers

The history command: See other users command history

Can anyone tell this: If two users are logged into the same server from different locations. Is there a way to see the history command of the other user? I tried the history command, but it is showing me only the commands I used. Thanks in advance for your help. Iamnew2solaris (1 Reply)
Discussion started by: iamnew2solaris
1 Replies

5. UNIX for Advanced & Expert Users

History to Another file [local user history , but root access]

Hi all, My need is : 1. To know who , when , which command used. 2. Local user should not delete this information. I mean , with an example , i can say i have a user user1 i need to give all the following permissions to user1, : a. A specific directory other than his home... (3 Replies)
Discussion started by: linuxadmin
3 Replies

6. UNIX for Dummies Questions & Answers

How to review the history and the commands that has been done in this history?

Hello every body, Kindly inform me How Do i find out the time I executed a command previously on UNIX Solaris?? To be more specific and more clear about what i want to know is that I want a command the enables me to know the history and which command i run at this history/time. FYI I used... (5 Replies)
Discussion started by: ahmedamer12
5 Replies

7. UNIX for Dummies Questions & Answers

Alternative to saving history

Hi! We have a non-root account in which history is disabled. Is there any other way to save commands that get executed through that account. I don't have root privileges on the system. Please suggest... Thanks, Jack. (1 Reply)
Discussion started by: jacki
1 Replies

8. UNIX for Dummies Questions & Answers

Extracting lines and saving - awk

Hi All, I am trying to extract lines bsed on pattern matching../mp straight-flow/ Extracted output should be saved in meta_string , but the code is not working in that manner,saving repeated lines. can anyone please suggest where am i going wrong. /mp straight-flow/ {... (6 Replies)
Discussion started by: madhaviece
6 Replies
Login or Register to Ask a Question