Bash is a free shell for Unix-like operating systems, from the GNU Project

learn more… | top users | synonyms

2
votes
1answer
234 views

Newly created files are ALWAYS executable by default -(cifs,NAS)?

I messed with file permissions on my NAS - My Book Live - which runs on Debian Lenny. Now, every file I make is set executable by default. This happens only on the machine the NAS is mounted to. When ...
-1
votes
4answers
409 views

How to set a file NOT no be executable - linux terminal?

The question is that I want to toggle of the executable bit of a linux executable I know that I can set a+x executable, but I can't set is as NOT executable :( Google omits not from searches..
2
votes
1answer
517 views

SSH Session Started from Here Doc Does Not Exit Properly

SSH session doesn't terminate and give the tty back when executed inside a here document. Below is the code snippet that's inside my shell script: ssh -t -t root@$HOST_ADDRESS <<TERM_STRING cd ...
4
votes
1answer
2k views

Whitespace is collapsed with echo >>

I am creating a script that reads the contents of a file, manipulates the contents and appends to another file (specifically the virtual hosts file). The formatting and whitespace in the output file ...
0
votes
1answer
423 views

How can I run a command on every file in a given directory?

I am using mp4box to move the MOOV atoms on MP4 files. The thing is, I will have 6 files in a given folder and I don't want to run the inter 500 command six separate times. Is it possible to do ...
-4
votes
1answer
61 views

Syntax for Functions in Bash

I do know the JavaScript syntax: var functionName = function(some perameter){ some code here; }; but what is the syntax for a function in bash?
2
votes
1answer
332 views

Bash: save ffmpeg output to a variable

How can i save ffmpeg file-info output to a variable? if i put the following command into variable it's always empty, even though the command generates an output /usr/bin/ffmpeg/ffmpeg -i $1 what ...
0
votes
1answer
205 views

How do bash scripts expand file globs?

In this code, the excludespec variable is expected to match all it substring, but it appears to evaluate the to the actual files matching it when it is executed, rather than pass its exact ...
2
votes
1answer
245 views

Can only use some commands as sudo

I have had a bit of a problem with some commands lately, not working as intended. I wanted to fiddle with some Markdown and try it as a substitute for some simple HTML pages, so I looked into some ...
5
votes
2answers
177 views

Differences in bash scripts between $@ and $*

Which are the differences between $@ and $* ? For example I see no differences here: #! /bin/bash echo with star: $* echo with at sign: $@
6
votes
4answers
4k views

Get the parent directory for a file

I want to get just the name of the parent directory for a file. Example: When I have path=/a/b/c/d/file, I want only d and not /a/b/c/d (which I get from dirname $path) as output. Is there any ...
4
votes
3answers
125 views

Transparent usage of temporary files as means of piping

As many of us are surely aware, it's always a good idea to make your program accept stdin input. Very many programs do allow that *nix environments. This lets us do cool things like piping echo "foo" ...
0
votes
1answer
560 views

How do I set the Android bash path in ZSH?

Looking through the Cordova Android docs, I see this line You need to add the path to your Android SDK platform-tools and tools directory. In my example I will use ...
4
votes
3answers
305 views

why “cd -” in .sh file will print the address

I use "cd -" to switch between folders. like: cd /etc/ cd - but why "cd ...
0
votes
2answers
329 views

How to permanently reset my $PATH?

I was trying to add something to $PATH and it went totally wrong. I now can't run any commands such as ls. I've looked at this answer ...
2
votes
3answers
2k views

Move a list of files(in a text file) to a directory?

I have a list of files, with their full paths, one per line in a file "files.txt" I was trying to move all of those files from their original location to a new directory. I CDed into the directory ...
3
votes
1answer
361 views

Bash 4.2 doesn't complete directory names

I have a problem with bash completion after a system upgrade. $ mkdir abcde $ cd abc[TAB] does nothing, while in the older bash versions it would expand to $ cd abcde. Some older forum on ...
0
votes
1answer
4k views

Timezone conversion in bash script

I found a solution about how to convert timezone with the Linux date command: Timezone conversion by command line $ date --date='TZ="Asia/Taipei" 18:00' Fri Jul 16 11:00:00 BST 2010 It's working ...
47
votes
2answers
6k views

How can Homebrew print a beer mug in Terminal?

Homebrew has a neat trick of printing out little icons next to its output. Like this: If I copy paste the icon it on its own and hit enter I get the result: -bash: $'?\237\215?': command not found ...
2
votes
1answer
999 views

Open Sublime Text 2 with new tab instead of new window

I've got an alias to open files in Sublime Text 2: alias sub='/Applications/Sublime\ Text\ 2.app/Contents/MacOS/Sublime\ Text\ 2' But this spins up another instance of Sublime Text 2 (complete with ...
7
votes
3answers
8k views

grep for “term” and exclude “another term”

I am trying to build a grep search that searches for a term but exludes lines which have a second term. I wanted to use multiple -e "pattern" options but that has not worked. Here is an example of a ...
2
votes
1answer
1k views

Nice commands in a .sh script for cron jobs

I have this php script that I need to run on shared webhosting. I have created a cron job that executes an sh script. The command for the cron was: /bin/sh /home/user/script.sh So I'm assuming it is ...
7
votes
5answers
6k views

How to echo commands in a bash shell script, but not execute them?

Is there a way for running a shell script with echoing the commands but w/o actually executing them? Let's say I have script removing a file whose name is stored in a variable: #!/bin/bash set -v ...
56
votes
2answers
2k views

Make bash terminal cursor flash to the beat of Survivor - “eye of the tiger”

I was listening to Survivor - "Eye of the Tiger" and writing some documentation in Vim and noticed that the cursor not flashing to the beat started to annoy me. Can this be fixed? I'm using ...
2
votes
3answers
2k views

How can cat/print a file except the last 2 lines?

How can get a file, except the last (for instance) 2 lines, with standard or GNU shell tools? (bash, tail, cat and so on.)
3
votes
3answers
168 views

Run command on shell and get output in vim

I know how to run shell commands within vim using :!r and :!, but is there a way I can do that from outside, i.e. from bash? Something along the lines of vim 'ls -al'. The output of ls should be in ...
4
votes
2answers
446 views

why error code 1 returned by loading .bash_profile in Mac

Whenever I open a bash terminal, the error code 1 is returned: Last login: Tue Jan 15 16:19:53 on ttys000 spam@moss:~ $ echo $? 1 I found this is caused by last line of code in my .bash_profile: ...
0
votes
1answer
3k views

How can I make script globally executable in Ubuntu?

I have a bash script which I would to like to execute from everywhere (like other Linux basic commands, for example ls). I tried to follow this tutorial but it doesn't work, I always get command not ...
0
votes
1answer
999 views

Bash: changing font size

This will change the font to yellow: echo -e "\E[1;33m" How exactly can I make it bold and increase the font size, whilst keeping the yellowness?
0
votes
2answers
633 views

Capturing the console output

I am running a Hadoop hive query from shell script. This is how I am doing it in my shell script. echo "SELECT COUNT(*) FROM test" | hive I want to capture the output whatever hive command outputs. ...
5
votes
3answers
365 views

Can't assign to PS1 on OS X bash

I'm trying to set up PS1 so it displays the branch name on git: user.name:some/repo (master) $ However, nothing I do seems to work. Even when I just try assigning to PS1 directly, it doesn't work: ...
1
vote
2answers
218 views

What determines what shows up in the bash history command?

When I run history, I get a list of commands. However, it does not appear to be complete, even for a given period of time. (It doesn't feel like it has continuous coverage of the past N commands - it ...
1
vote
1answer
79 views

in place refreshing of a large tar.gz?

I have a directory with about 300Mb of code and data, and I need to regularly change a few lines of code in a few of the files and repackage the directory into a new project-version.tar.gz. It takes ...
0
votes
1answer
534 views

Running tcpdump on remote machine with no tty using ssh

I'm trying to start tcpdump on several remote machines to perform some network analysis with a script, but I'm failing to run it correctly. The command I would like to use is: ssh user@host ...
1
vote
2answers
892 views

How to execute command, and if it fails, execute another command and return 1?

I'm used to this style in other languages: do_something || (log_error; return 1) # do something, and if that fails, log the error and then return 1 no matter what, even if the logging fails. But I ...
2
votes
1answer
864 views

ssh Mac Unix: copy a file with special characters and spaces

I am remote logged into a Mac and trying to copy a music file from one directory to another, but I am getting an error. I think it's caused by spaces or special characters, but not sure. the file ...
1
vote
1answer
171 views

rm !(myfile) does not work on OS X?

The command works fine on Linux but on OS X Mountain Lion when I'm doing: rm !(myfile) bash complains: bash: !: event not found Is there any way to do it the same on OS X?
0
votes
2answers
79 views

rsync {braces} fail?

I need some help in this issue: I want sync /path/first/ with /path/second/, /path/third/ ..etc so I've tried this: rsync -rv /path/first/ /path/{second,third,fourth}/ But it worked only for last ...
0
votes
1answer
469 views

Downloading and extracting a .tar to a specific directory

I want to download a tar of a git repo and extract its contents to another folder. The following line (broken up for clarity) works: curl -L -0 nt-dotfiles.tar.gz ...
2
votes
2answers
95 views

Efficient environment for viewing logs [closed]

Currently I am using tail -f for viewing logs. Is there any more efficient/readable/better way of viewing logs?
1
vote
2answers
175 views

How do I use Bash in VirtualBox?

Just started using VirtualBox. I have an ubuntu iso image on my usb that I can boot from. I ran ubuntu in VirtualBox in Window7 with no problem. How can I go about using Bash with Linux in VirtualBox? ...
1
vote
2answers
522 views

Interfacing strace with Process Name instead of PID

How do I implement a wrapper script pstrace in bash that changes the interface of [sudo] strace -c -p [PID] to [sudo] pstrace -c -p [PROCESS-NAME] similar to how killall [PROCESS-NAME] is ...
1
vote
3answers
156 views

Dealing with files/folders with spaces in bash script

I need to search for places.sqlite on a system which may have spaces in the folder name; This works without spaces in folder name: for each in `find /home/ -name "places.sqlite" | grep -i ...
0
votes
0answers
151 views

rsync shell script

Need some hints on my first shell-script using rsync. I use rsync, because I had some trouble with a graphical Backup that ran twice and now I want this example as shown below to work on two external ...
0
votes
1answer
99 views

Fork processes in a script using different colors for each process output

I have a script that operates on 4 folders. Because they are completely independent, I'm passing in the folder path to a function and then forking that function. It works, but the output to the ...
1
vote
1answer
277 views

How do I print a tree with files in Bash for Windows?

I've found this command to show a tree of the directories under the current one: ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/' Which produces: ...
4
votes
5answers
5k views

How to display the file contents recursively?

I always have to submit the source codes in my printed assignment report. I have to copy and paste my course codes into the document and I find that it is an annoying task. I want to solve this "copy ...
1
vote
1answer
224 views

Cygwin browser script error

I use multiple browsers, and I created a bash script that checks to see which browser is open and opens web pages in whatever browser is already open. I use Windows 7, so I run this script using ...
0
votes
1answer
190 views

I changed the symbolic link /bin/sh by accident

I am working on Ubuntu 11.1. The symlink /bin/sh pointed to dash in my system. /bin/bash pointed to sh. I accidentally changed /bin/sh to point to /bin/bash. Now, I can't open the terminal. How can I ...
2
votes
1answer
63 views

ssh not working with yes

I had to solve a fringe case lately where I had to add a number of server fingerprints to a user's known_hosts (the authorization is performed with a keypair). I thought the easiest solution would be ...