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

learn more… | top users | synonyms

0
votes
0answers
20 views

how to find packages in subdir with a particular dependency

From the root of new SLES media how is it possible to find all packages with a particular package dependency? That is, there are many RPMs in various sub-directories of root. How may I find all ...
0
votes
3answers
25 views

How do I move files from many child directories into my root directory?

I'm using bash on Mac 10.9.5. I have PDF files in many directories, all one level from the root ... Dir_1/abc.PDF Dir_2/def.PDF Dir_3/ghi.PDF Dir_3/jkl.PDF ... How do I write a shell command to ...
3
votes
6answers
2k views

loading local shell aliases to ssh session dynamicaly

When I log in to some machine using ssh I wish my aliases and functions are there. In other words, log in to some machine I wish I can use my command shortcuts. I need it be dynamic, every time I'm ...
-1
votes
1answer
26 views

for loop in if else conditions in bash [closed]

I'm trying to script the following task. I have a file in which node name and ips are updated, I have to make each file of those nodes which are not in our required directory and those are in updated ...
0
votes
3answers
75 views

Print previous 20 lines of text from a certain point of a text file

Currently: I'm new to scripting, teaching myself as i go along and this is my first script I'm developing. What my script is trying to do is look at specified file, scan the file to find the word ...
-1
votes
0answers
9 views

How to remove the source file when converting with LAME via Automator and a shell script?

I have been trying for hours, doing searches on Google, but I can”t find the syntax. I am doing an “Automator” workflow, and I have this code in a Shell script:
2
votes
3answers
46 views

Apparent .bash_profile and .profile conflict in Mac OS X

I have an issue where, when I load up new terminal windows, I have to source the ~/.profile to get my PHP path working correctly. In essence of my issue is getting terminal to use MAMP PHP and MySQL ...
1
vote
1answer
23 views

Difference between : and := with variables in bash files

I came across a bash file which has something like this MYVAR := SomeVal I know after reading some tutorials you set values as such MYVAR = SomeVal What is the difference between the above two ? ...
0
votes
1answer
38 views

Non-interactive ssh sessions don't have PATH set on some systems

I set my environment in .profile. My .profile is idempotent and .bash_profile, .bashrc, .kshrc and .zshrc all source .profile. That way I always get the same environment regardless on what ...
12
votes
1answer
20k views

How to list printer names acceptable for use with lpr?

The lpr man page says a destination printer can be specified with the -P flag. -P destination[/instance] Prints files to the named printer. I have 'added' various printers on local Samba shares ...
0
votes
1answer
33 views

Download multiple files from ftp server with bash script

I have 2 or 3 FTP Servers where our hoster puts database backups each day. Since he only keeps one, I was orded to write a bash script for downloading alle database backups every day so we have more ...
50
votes
9answers
51k views

Remove a certain line from Bash history file

How can I remove a certain line from history's database?
19
votes
4answers
4k views

Substitution in text file **without** regular expressions

I need to substitute some text inside a text file with a replacement. Usually I would do something like sed -i 's/text/replacement/g' path/to/the/file The problem is that both text and replacement ...
0
votes
0answers
19 views

static ip address disappeared in the middle of running iperf

The following is done on iperf client side. I set the static ip address for eth0 by modifying /etc/network/interfaces, and activate the change by doing ifup eth0. Then I start iperf -c $server_ip -t ...
2
votes
2answers
520 views

Disable Bash's programmable autocompletion (based on command)

Bash in my Fedora 16 seems to autocomplete arguments based on the command itself. So if I for example type cd Tab … it will only show directories. There are however far too many commands where ...
0
votes
1answer
26 views

Python debugger not stopping at breakpoints

I'm in a linux based development environment where I don't have superuser permissions. My basic issue is that the breakpoints I set in emacs through pdb never work. The debugger never halts at those ...
0
votes
1answer
10 views

What is KNOPPIX shell's start-up file?

I'm trying to install virtualenvwrapper and I got to change the settings of my shell's start-up file (like .bashrc, .zhrc, .profile, etc) to write this: export WORKON_HOME=$HOME/.virtualenvs export ...
0
votes
1answer
92 views

Require bash script to be run with sudo (not as root user)?

I want to require a bash script to be run as the current user with sudo, but prevent it from being run if it was executed as the root user directly. This is because I'm doing some setup actions for ...
1
vote
0answers
26 views

Expression within shell script [migrated]

I have just seen this code, but i can't get my head around how this code can actually work. For my understanding it shoud just echo out everything, or am I wrong? deleteOldDumps(){ local SYSTEM="$1" ...
4
votes
2answers
995 views

Is there a ”reverse incremental search” functionality in Fish similar to Bash’s <kbd>ctrl</kbd>+<kbd>r</kbd>?

I’m really impressed with Fish’s autocomplete functionality. However there is one feature in Bash that I’m unable to find in Fish. When you press ctrl+R in bash and begin to type out a term, a search ...
1
vote
0answers
14 views

How to show git branch in Emacs shell

How can I show the current git branch as part of the Emacs shell prompt? For example, I have this in my ~/.bash_profile (I'm on Mac OSX 10.9 Terminal): parse_git_branch() { git branch 2> ...
-1
votes
0answers
26 views

Undoing a sudo command

In a fit of frustration, while installing node via nvm, I followed the steps listed in a Digital Ocean post: I am most concerned about this command: n=$(which node);n=${n%/bin/node}; chmod -R 755 ...
1
vote
0answers
17 views

Can I have server and client on the same machine and run network bandwidth test using iperf?

I have two ethernet ports (eth0 and eth1) on my system. I've tested the bandwidth with two systems and got ~940Mbit/s. If I use one of the ports as server and the other as client, I always go through ...
0
votes
3answers
38 views

Multiline && combinator operator for command chaining in batch file

I see that this operator is used in windows (and might be Linux?) to chain/combine multiple commands in one line. Commands are executed one after another, as long as preceding complete successfully ...
0
votes
1answer
50 views

Percent sign in bash is not typeable

I have a strange problem: I cannot type or copy the percent sign in my bash... I tried to read ~/.bashrc, /etc/profile (and stuff in /etc/profile.d). I also tried sudo bash, but still not possible to ...
71
votes
12answers
44k views

How to get git-completion.bash to work on Mac OS X?

I have followed http://blog.bitfluent.com/post/27983389/git-utilities-you-cant-live-without to add git-completion.bash to my /opt/local/etc/bash_completion.d/git-completion and I put ...
2
votes
1answer
74 views

How can I check if a file is newer that the target file in a shell script

How can I check if a file is newer that the target file? In a shell script, intended to run on a Mac, I want to do something like this: #!/bin/bash if [ $SourceFile dateisgreater $TargetFile ] then ...
1
vote
2answers
18 views

How do I output this line to a remote file?

I'm using a bash shell and trying to figure out the right way to write the following: ssh mysuer@remotehost 'echo "update user set url = \'localhost\' where url = \'mydomain.com\';" >> ...
14
votes
4answers
7k views

How do you escape apostrophe in single quoted string in bash?

I don't understand how bash evaluates escaping of apostrophe characters in single quoted strings. Here is an example: $ echo ''\''Hello World'\''' 'Hello World' # works $ echo '\'Hello World\'' ...
0
votes
1answer
58 views

Test USB 3.0 Device Speed

I've looked up hdparm, but all examples are for testing disks. Not sure if it can be used to test external usb devices (specifically usb flash stick). I'm using the following code right now: dd ...
0
votes
1answer
26 views

How is the “builtin” bash command defined?

I noticed that command like cd .. is actually converted to builtin cd .. and then executed. But how is builtin defined? which builtin doesn't show anything and it's not in /bin, /usr/bin etc. Is it ...
0
votes
1answer
22 views

Duplicate a remote session in terminal in Linux (Ubuntu)

How do I duplicate a remote session in the Linux (Ubuntu) terminal? For example, if I have an SSH session open, how can I duplicate this session in the terminal?
1
vote
0answers
27 views

Cygwin and Cygwin64 missing prompt in terminal

I tried to install and reinstall cygwin and cygwin64. I also tried different mirror sites. Instead of seeing a line like user@PC~ $, I see a blank screen with a blinking cursor. The properties of ...
0
votes
1answer
34 views

Resolved: Enumerating every other array element in loop

I have a dynamic array with key-pair values and I’d like to enumerate every other value. In this case, just the names in the array. Since I’m not using bash v4, I have been able to use seq to step ...
0
votes
2answers
188 views

Ctrl+Z and fg to append commands

I would like to know what is the behaviour of Ctrl+Z and fg in bash when wanting to append commands to be executed after a running command has finished. For example, in the sequence for commands ...
1
vote
1answer
13 views

Advanced Wget usage

I have a list of about 200 servers which contain links to individual files, for this question, let's just pretend they're .txt files. I need to download every file, however some servers only have the ...
1
vote
2answers
45 views

bash complete: list directory names from a defined directory?

I need the directory names in /mailman/lists to tab-complete as an argument (without any slashes) to the 'list_members' command regardless of where I am in the filesystem. In tcsh (on our old ...
7
votes
7answers
8k views

How to write a script that accepts input from a file or from stdin?

How can one write a script that accept input from either a filename argument or from stdin? for instance, you could use less this way. one can execute less filename and equivalently cat filename | ...
-1
votes
0answers
29 views

echo giving syntax error, but only when run from cron

This script date +" %Y-%m-%d (%a)" >> $JURGEN/Jurgen/tracking/oldestActions.txt naSort | head -n 1 >> $JURGEN/Jurgen/tracking/oldestActions.txt works fine run from the command line, ...
0
votes
1answer
25 views

Mac OS X seems to be unable to find directry that certainly exists

For some reason Mac OS X cannot find a directory I just made. Any idea why? sh-3.2# mkdir /Users/Administrator/Documents/drive/ sh-3.2# mount -w -t "hfs+" /dev/disk1s2 ...
1
vote
1answer
45 views

Bash: better way to output to both console and output file than tee?

What I need to display is a log refreshing periodically. It's a block of about 10 lines of text. I'm using |tee and it works right now. However, the performance is less satisfying. It waits a while ...
0
votes
2answers
27 views

Adding subtitles for multiple mkv files by MKVmerge using terminal

I'm trying to adding subtitles for multiple mkv files. I use this script for doing this : for file in *.mkv; do "/Applications/Mkvtoolnix-7.0.0.app/Contents/MacOS/mkvmerge" -o "${file%\.*}(1).mkv" ...
24
votes
1answer
4k views

How can I get bash to perform tab-completion for my aliases?

I have a bunch of bash completion scripts set up (mostly using bash-it and some manually setup). I also have a bunch of aliases setup for common tasks like gco for git checkout. Right now I can ...
0
votes
2answers
47 views

bash one-liner while loop to ssh into internal IP or external IP

I would like to have a while loop on my terminal screen that tries to ssh into my server every second. At the moment it looks something like this: while true; do echo INTERNALIP && date ...
1
vote
2answers
3k views

How to auto commit to my git repository using cron?

I look into a lot of answers about this subject, but something is wrong here, let me explain. I create this script, to make my cron cleaner :) #!/bin/bash cd ...
5
votes
2answers
200 views

What's the differences between all the shells, zsh, bash, csh…, why are there so many? [on hold]

My understanding of shell is an interpreter between me and the OS. So it will translate my command and call the right program to perform it. For this simple task, why there're so many shells existing? ...
0
votes
1answer
20 views

Linux sort Command: how to sort on a number embedded in a field?

I'm on RHEL 6 using BASH. I'm trying to sort some lines in a file, by a number that is embedded in a field. The name of the file is word.txt. This is the command I am using: sort -n -k4 word.txt ...
5
votes
3answers
8k views

How can I start multiple screen sessions automatically?

I'm trying to build a command that launches screen, creates four sessions with different names, and run four different commands. I know how to do this manually: 1. screen 2. ./command1 args 3. ...
6
votes
4answers
4k views

Are there other commands like scp but for deleting files and folders?

I am using scp to copy stuff to a remote location. But sometimes scp does not work as expected, I have found that sometimes the copy does not complete properly (possibly when I have added new files to ...
0
votes
0answers
20 views

S3 Upload via CURL fails when triggered via cronjob

I'm using a script dump-to-s3.sh to put database dumps in a S3 bucket. When triggered manually it works perfectly but when I trigger it via this cron (as root crontab) it fails with the following ...