Questions tagged [bash]

Bash is the shell from the GNU project. It is the standard shell on many Linux distributions and often available on other *NIXes.

Bash (the Bourne again shell) is a Unix shell. It was intended as a free replacement to the Bourne shell and includes many scripting features from ksh. Bash is intended to conform to the POSIX 1003.2 standard.

Bash also includes more advanced interactive features such as command line editing with the library, command history, job control, dynamic prompts and completion.

Links and documentation

Books and Resources

37 questions
55
votes
16 answers

Why such popularity with Python?

Other than being annoyed at whitespace as syntax, I'm not a hater, I just don't get the fascination with Python. I appreciate the poetry of Perl, and have programmed beautiful web services in bash & korn, and shebang gnuplot. I write documents in…
Jé Queue
  • 3,937
  • 2
  • 29
  • 37
23
votes
2 answers

Share private SSH keys with Bash on Windows

I have Windows 10 with Git installed. This Git uses my C:/Users/MyName dir as the HOME directory and the /.ssh/ dir within, appropriately for sourcing my private SSH keys. I have just enabled and setup "Bash on Ubuntu on Windows" (what a mouthful!)…
Toby
  • 595
  • 1
  • 6
  • 13
14
votes
3 answers

When is it appropriate to use colour in a command-line application?

Currently I have a command-line application in C called btcwatch. It has a -C option that it can receive as an argument that compares the current price of Bitcoin with a price that was stored beforehand with -S. Example output with this option is: $…
13
votes
3 answers

User Configuration of a Shell Script. Best practices?

I am writing a shell script with a few variables that should be configured by the user. There will be an installer for downloading and configuring the script, possibly by asking a series of question. The script in question is aimed at other…
12
votes
5 answers

How should I version control my bash profile?

So I'm very comfortable with version control, and just thought to start tracking versions of my bash profile: ~/.bash_profile with the added benefit of being able to share my various aliases and such on GitHub. Assuming that my .bash_profile file…
elliotwhitehead
  • 131
  • 1
  • 4
11
votes
5 answers

Is it good practice to require a trailing forward slash in directory names?

I want to ask the user of my bash script to pass a directory path as argument. Which one of the following is a good programming practice? Require that the user enter a trailing / (forward slash) Require that a user doesn't enter a trailing /…
Rohit Agarwal
  • 343
  • 3
  • 8
10
votes
1 answer

Is it possible to use python as a shell replacement?

Recently I was looking at python's shutil and subprocess etc... And I started wondering: wouldn't it be ok to use python instead of e.g. bash? What am I missing?
xtofl
  • 334
  • 2
  • 10
10
votes
5 answers

Improving performance for grepping over a huge file

I have FILE_A which has over 300,000 lines and FILE_B which has over 30 million lines. I created a Bash script that greps each line in FILE_A over in FILE_B and writes the result of the grep to a new file. This whole process is taking over 5…
rogerio_marcio
  • 103
  • 1
  • 4
7
votes
1 answer

Are these steps enough to put my bash script under GPL 3?

I have written a bash script I would like to put under GPL v3. I've read the GNU documentation on How to Apply These Terms to Your New Programs and How to use GNU licenses for your own software. Still, I'm not quite sure what to put there and which…
Oliver Weiler
  • 2,448
  • 19
  • 28
6
votes
2 answers

Anything wrong with having aliases on a production server?

On my local server, I create aliases like these to speed up my work: alias bashrc='vi ~/.bashrc;source ~/.bashrc;echo bashrc has been sourced' alias bashprofile='vi ~/.bash_profile;source ~/.bash_profile;echo bash profile has been sourced' alias…
Nav
  • 1,173
  • 1
  • 11
  • 23
6
votes
2 answers

Is bash "finished"?

Should bash be expected to change in ways that break non-trivial amounts of existing scripts at some point in the (near/<5y) future? How much change has it gone trough in the last ten years compared to, say, python or perl?
user46637
6
votes
6 answers

PHP as a scripting language

I have reasonable knowledge of PHP, Perl, and Bash. I use Perl for most text processing on my system (find, replace, filter output, etc). I use PHP for web development, allowing a user to view and interact with database data via the browser. I use…
Alan Turing
  • 1,533
  • 1
  • 16
  • 20
5
votes
4 answers

Shell commands in bash or python? How much encapsulation is too much?

I'm thinking about how to decide whether it's better to encapsulate my work behind well-named function names, or to expose it - which will help developers understand what's going on more quickly? Is there a name for the study of this sort of…
Robin Winslow
  • 533
  • 4
  • 14
4
votes
2 answers

Are "backwards" terminators for if and case unique to shell scripting?

In bash at least, if and case blocks are closed like this: if some-expr then echo "hello world" fi case $some-var in [1-5]) do-a-thing ;; *) do-another-thing esac as opposed to the more typical close of end or endif/endcase. As far…
3
votes
3 answers

Recommended guidelines for declaring bash/sh variables

I have been programming in BASH for a while now and the scripts that I write are starting to get more complicated. I realized that I started to bring in some habits from C/C++ and wanted to get confirmation on if I needed to break my current habits…
1
2 3