Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Sometimes I try to search some command by CTRL+R and it's not found,
while I recently used it or search by CTRL+R with success.
Afer I run `history I'm able to find the command again.
Is this behavior is normal?
How it can be changed?
Ctrl+R searches backward from the current position in the history, so if you already moved that position you'll miss the parts toward the end.
e.g.:
themel#kallisti: ~ $ foob
bash: foob: command not found
themel#kallisti: ~ $ barz
bash: barz: command not found
themel#kallisti: ~ $ barq
bash: barq: command not found
themel#kallisti: ~ $ quarg
bash: quarg: command not found
Ctrl+R,bar yields:
(reverse-i-search)`bar': barq
but also moves to that point in history - if you subsequently do Ctrl+R and search for quarg, you won't find it. This is reset by remedied by using end-of-history (M-> by default) to re-set the index.
Related
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 3 years ago.
Improve this question
Suppose I have the following code in a StackOverflow response:
$ export FLASK_APP=main.py
$ export FLASK_DEBUG=1
$ python -m flask run
Is there an easy way to copy and paste this without the $ signs, so I can directly paste this into my terminal?
You could do:
. <( sed 's/^\$ //' <<'PASTE'
**paste here**
PASTE
)
Or, make that into a function:
undollar() { . <( sed 's/^\$ //' ); }
Than you use that like
$ undollar<hit enter>
<paste here>
<hit Ctrl+D>
Both of these approaches use the . command, so effects are seen in the current shell: for example with the commands you list, the FLASK_APP and FLASK_DEBUG environment variables remain in the shell.
As noted by Charles Duffy, old versions of bash cannot source a process substitution: see Why source command doesn't work with process substitution in bash 3.2?
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'm trying to run a script in my Terminal on OSX. I run it like this:
$ script.sh input.txt output.txt
-bash: Script.bash: command not found
This script has worked before (with no changes to it) and it appears in the working directory when using the ls command. I don't know if this means anything but previously my script files had a .s logo on their filetype picture and now it is blank, like a .txt file (in Finder). Any help would be much appreciated! I tried using script.bash and the same thing happens. Thanks!
try "./COMMAND HERE"
or ". COMMAND HERE"
you need to have an explicit path if the script isn't in your $PATH
./script.sh input.txt output.txt
also you will want to make sure that the script is set as being executable
like:
chmod 777 script.sh
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I am using Terminal(Mac) for git.
When I use it shows mySystemName-MacBook-Pro:CurrentWorkingDir mySystemName before $ sign.
In my case the whole content is too long and hardly remains few space to write commands.
I want to rename it and use a alias so that there may be more space for the git commands.
In Short I want From this:
mySystemName-MacBook-Pro:CurrentWorkingDir mySystemName $
to this:
aliasName $
PS1="aliasName \$ "
man bash
...
PS1 The value of this parameter is expanded (see PROMPTING below) and used as the primary prompt string. The default value is ‘‘\s-\v\$’’.
...
PROMPTING
\w the current working directory, with $HOME abbreviated with a tilde
\\ a backslash
...
...
...
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
There is a file in my home directory that is called #snake#. I want to remove it but none of the regular remove commands will work. How can this "file" be removed without causing any damage, and what type of file is it?
It's an autosave file, it's there in case your computer crashes. You can delete these from emacs quite conveniently. Open up dired (C-x d) and press # to select all of them in the directory. Then x for delete.
Alternatively in a shell, just put the name in quotes, e.g. rm "#snake#"
The "problem" is that the # sign is interpreted as the start of a comment in a shell. Try enclose the file name in quotes, like:
rm "#snake#"
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Have I found a bug in bash?
I have created a folder named Test
cd Test/
rm -rf ../Test (Deleted the PWD while I was in that directory, as shown in image)
Not a bug, not related to bash either. You're current working directory (and all the environment variables that hold the path info in your shell) is simply pointing to a filesystem node that's been orphaned. Listing it will give you what's in the node, which is nothing because . and .. are gone (because it's orphaned). Note that rm removes everything in the directory before orphaning the node. Thus, ls gives you nothing.
Also note that when you try to create a file while inside the deleted directory with something like touch blah or mkdir blah, it'll give you a file not found error.
"orphaned" may not be the correct term, I'm simply using it to mean that it has no parent node.