LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-05-2020, 11:06 PM   #1
BudiKusasi
Member
 
Registered: Apr 2017
Distribution: Artix
Posts: 345

Rep: Reputation: 15
bash history wrap around to the first command


How do we have bash history wrap around to the first, oldest command when at the latest, newest command?
 
Old 08-05-2020, 11:56 PM   #2
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,732

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Um
Code:
history | more
??
 
Old 08-06-2020, 01:17 AM   #3
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
What do you mean by "history wrap around"? History is in a file, normally $HOME/.bash_history, and has a first command and a last command.

Do you mean a command that goes back in history and, when it reaches the first line, goes to the last?

By default, history viewing and editing uses emacs commands. Try to find what you want in the emacs manual. You can also use vi as the history editor (set -o vi).

However, I doubt that either emacs or vi have cursor movement commands that wrap around.

I am curious - why do you need this feature?
 
Old 08-06-2020, 02:18 AM   #4
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
Not the answer to your question, but I use HSTR to navigate bash history.
 
Old 08-06-2020, 03:40 PM   #5
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by berndbausch View Post
However, I doubt that either emacs or vi have cursor movement commands that wrap around.
Normally, "^r" (reverse search) at the command line will search backwards in the history file for a given command/string. In Emacs itself, "^r" will wrap around when reaching the beginning of the file and resume searching at the end. However, it does not wrap around the beginning/end of the command line history---at least it doesn't the way my environment is set up.
 
Old 08-06-2020, 07:40 PM   #6
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,337
Blog Entries: 28

Rep: Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144
This thread from Stack Exchange might help: https://unix.stackexchange.com/quest...search-in-bash
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Wrap quotes around a path/file name before passing to a command taylorkh Linux - Newbie 6 02-26-2018 04:56 AM
[SOLVED] Wrap quotes around string in a bash script taylorkh Linux - Newbie 5 12-24-2017 09:37 AM
Why does BASH history command have no history when run in script ? lump_of_lard Programming 4 01-30-2015 09:45 AM
Trying to wrap my head around bash eveningsky339 Programming 5 12-02-2010 01:47 AM
"enscript --word-wrap" does not wrap line of text file powah Linux - General 3 05-16-2006 09:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration