Unix command for picking out run commands [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I am relatively new to linux environment. My doubt is this:
I run a lot of commands of various types , so when ever i want to rerun a old one i have to look through the entire history. is there any bash command that displays just the commands that begin with a particular combination of characters( my case here is i just want a list of all the ./ eg: ./ifv_script , ./run_regression i've run from the terminal)

Three methods:
You can grep your current history, e.g.:
$ history | grep ifv
You can also recall commands from the history by typing ControlR and then type a few characters from the command.
Finally you can grep your saved history file for older invocations from previous sessions, e.g.:
$ grep ifv ~/.bash_history

Just press Ctrl+R, and you will enter into reverse-i-search mode.
Now you can type a few characters that appear anywhere in the command and bash will start finding matches.

Final approach (bash only):
history | grep term

Related

How to limit terminal output of a bash command in a script [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
(EDIT)
I am creating a bash program that has many fully featured options as a networking program written in python. In my program, I am using the below command and it's specific output will be used as a variable.
I am looking for a command or method to display only specific terminal output of a command. For example if, in my script, I use the command:
iwconfig wlan0
Yet all I wish to see from this command is what mode in which wlan0 is set. (i.e. Master, Managed, Monitor, etc.)
I have looked and searched all over Google and Bash specific sites and cannot find a solution. I may be overlooking something.
The grep option you're looking for is -o, or --only-matching in its long form. It outputs only text that matches the search you gave it, and nothing else. For example:
iwconfig wlan0 | grep -o 'Mode:[^ ]*'
outputs Mode:Managed on my machine. The single quotes are necessary so that the shell won't try to interpret the [, ] and * characters (with double quotes, if you happened to have a file with precisely the wrong name in your current directory, the shell might wrongly expand your parameter to the name of that file). The regular expression inside the single quotes means "the text Mode:, followed by any number of non-space characters", which is exactly what you were looking for.

unlimited scrolling up from default linux command line [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I am looking to increase the default size of the scrolling up buffer from linux command line. It is a Debian server without gui.
I don't find related option in bashrc and I don't even know if there is other configuration file for the default prompt alt+f1 alt+f2 ...
You can change the scrollback-buffer size using kernel options as described here: https://wiki.archlinux.org/index.php/Scrollback_buffer .
However, if you are interested in the output of a command but at the same time you want to watch the command's progress interactively I suggest to use tee:
command | tee out.file
or if you want to append to a file use
command | tee -a out.file
tee is nice! use it! :)

search through the command history in the terminal [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Improve this question
Have you ever used a command in the Terminal, but then later forgot what you typed, and wished there was some way that you could view the last used commands?
There are many ways to search through your command history. Here are 3:
use the up and down arrows on your keyboard when at the command prompt.
use the history command.
Simply press : Control + R when at the command prompt.
E.g : Control + R , then write php
I often use bash-builtin command "history" to search for a certain command, e.g. to get the last sudo command type:
history | grep sudo | tail -n 1
gives the last command (with number) with sudo in it. "tail -n 1" gives the last matched line. Then use
!<number>
to execute exactely this command.
!-1
executes the last command, by the way. works well in bash.

How to detect which program will be run? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
Your system has 2 versions of the same utility installed, both which have the same filename.
How would you find out where the utility you would run by default is located?
If the utility's file name is "foo", type which foo
You'are looking for which command
which - shows the full path of (shell) commands.
Let's say you have perl installed in /usr/bin/perl and /usr/local/bin/perl and if the default path is the second one then
$ which perl
/usr/bin/local/perl
Check the $PATH.
echo $PATH
The first is started default.
or
which
Similar to which , whence gives you whence command from Korn Shell tells how a name would be interpreted by the shell: it detects commands and aliases, and searches your path.
whence {executable-you-are-looking-for}
and also in linux, just typing name & hitting tab will show list of available versions with which you can run.

How to delete file named "-d" in unix(Mac OSX) from command line? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I was playing with tail, head, cut and awk commands on a text file and somehow these commands created empty files with names "-d" and "-f2" (It could be due to ). Now I am not able to delete these files from command line since all commands take these as options. Of course I can delete these from Finder but I am wondering how to delete these from command line.
Use -- to separate the files from the command line arguments. That is
rm -- -d -f2
Or, you can use the full path or a relative path containing at least a /:
rm ./-d ./-f2

Resources