bash

How can you export your .bashrc to .zshrc?

I am trying to move to zsh from Bash. I put my .bashrc directly to my .zshrc, and it caused a lot of errors when I try to use Bash again. How can you export your .bashrc to .zshrc? ...

Syntax error : end of file unexpected (expecting "fi")

I am writing a makefile in bash and I have a target in which I try to find if a file exists and even though I think the syntax is correct, i still gives me an error. Here is the script that I am trying to run read: if [ -e testFile] ; then \ cat testFile\ fi I am using tabs so that is not a problem. The...

How can I escape characters in SQLite via bash shell?

I am trying to send a query to SQLite from the command line using bash. I need to escape both single quotes and double quotes, and escape them so that bash does not misinterpret them. Here is a typical query: select * from contacts where source = "Nancy's notes"; How can I send this query from the command line? The basic syntax is som...

Save last working directory on Bash logout

Is it possible to save the last working directory when you do an "exit" in bash. So, the next time you login, it will be at the directory you were at when you last logged out. ...

Unable to have a tab completion of system variables without a backslash

My inputrc is empty. I use Bash. Problem: I am at cd $te I press Tab, and I get cd \$test How can you have the tab completion without the backslash in Bash? ...

Surprise! the shell suggests command line switches

I noticed that the bash shell can suggest command line switches for your command. Just type your command, a dash (-) and type tab. The shell will show you available switches. For example, try: andy@andyx:~$ java - and press tab - Surprise! The question is: How do I interface with this feature. I.e., if I write a program that is ...

Moving files to a directory

I wanted to move all the files having certain patterns of the current directory to a folder. Example- I wanted to move all the files starting with nz to foobar directory. I tried it using mv but didn't work out well. ...

How to enable tab-completion of command line switches in bash?

With bash, I can complete a command with TAB. Normally, it should also complete the command line switches: e.g. when I typed: java - it should show me the possibilities. It does not. How can I enable this preview? See also Surprise! the shell suggests command line switches ...

How can I invoke VIM with C-X e for long, complex, tricky commands?

I found an awesome tip here. You can "[r]apidly invoke an editor to write a long, complex, or tricky command". However, when I press the key combination above, I get Emacs open. I would like to switch it to Vim. How can I invoke Vim with C-X e? [1. Problem SOLVED by Brian Cambell] export EDITOR=vim Add to your .bashrc or appropria...

Remove all .pyc files from a project

I've renamed some files in a fairly large project and want to remove the .pyc files they've left behind. I tried the bash script: rm -r *.pyc But that doesn't recurse through the folders as I thought it would, what am I doing wrong? Thanks ...

regular expression grabbing X amount of values out in linux bash

Hi guys wonder if you guys could help me I'm trying to compile a bash script that will display some values from a section of html code and I am stuck on the regular expression part, I have the following piece of code <li><div friendid="107647498" class="friendHelperBox"><div><a href="http://www.myspace.com/rockyrobsyn" class="msProf...

rm fails to delete files by wildcard from a script, but works from a shell prompt

I've run into a really silly problem with a Linux shell script. I want to delete all files with the extension ".bz2" in a directory. In the script I call rm "$archivedir/*.bz2" where $archivedir is a directory path. Should be pretty simple, shouldn't it? Somehow, it manages to fail with this error: rm: cannot remove `/var/archives/mo...

Unable to update my Bash in Mac by MacPorts

I updated unsuccessfully my Bash to 3.2.48 by MacPorts. It seems that I do not have it active, since I get echo $BASH_VERSION 3.2.17(1)-release How can you make the newest Bash active such that I get it for my login shell? ...

How can I execute javascript in Bash?

I try to get to a page straight from Bash at http://www.ocwconsortium.org/. The page appears when you write mathematics to the field at the top right corner. I tested open http://www.ocwconsortium.org/#mathematics but it leads to the main page. It is clearly some javascript thing. How can I get the results straight from Bash on th...

Unable to forward search Bash history similarly as with CTRL-r

I am trying to search my bash history similarly as with CTRL-r, but to forward direction. It has been a pain for me, when I just hit once too often CTRL-r, to find the previous command again. How can you forward search your Bash history similarly as in reverse searching? ...

Unable to find release notes for Bash

I need to find release notes for Bash from 3 to 4. I could not find them neither by google.com/linux nor by default google. I also looked unsuccessfully at gnu.org. Where are the release notes for Bash? ...

Unable to put colors for LS by LS_OPTIONS

I find out that you can have the following for Grep in .bashrc # puts colors for all grep commands export GREP_OPTIONS='--color=auto' I did not manage to get the similar command for LS_OPTIONS to work. Is there any other way than the following to give colors for your ls -command? alias ls='ls -Gh' ...

Unable to understand a line in .bashrc

I found the following code in one's .bashrc # Source global definitions [ -f /etc/bashrc ] && . /etc/bashrc It apparently caused my Bash duplicate a lot. What does the one-liner means? ...

Unable to use Checkjobs and Autocd in Bash 4

There are new commands in Bash 4: checkjobs and autocd. However, I did not find documentation for them at man bash I run unsuccessfully {checkjobs,autocd} I found the following in release notes There is a new `checkjobs` option that causes the shell to check for and report any running or stopped jobs at exit and There is a n...

Unable to enable globstar in Bash 4

I put the following unsuccessfully to my .bashrc shopt -s globstar I am trying to test the command in action by ls **/*.c and by comparing it to ls */*/*.c How can you enable globstar in Bash 4? ...