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

learn more… | top users | synonyms

2
votes
1answer
425 views

Is it possible to kill a loop in bash without killing the instance of bash running the loop?

Suppose I execute (in an interactive bash shell) a loop that spawns a bunch of processes in sequence, such as the following. for i in `seq 15 42`; do if [ -f F$i.flv.mp3 ]; then play F$i.flv.mp3; fi; ...
3
votes
3answers
363 views

Can't delete file with foreign letters

I have a file: På hjul.mkv When trying to move or delete file I get rm: can't remove 'På Hjul.mkv': No such file or directory The same thing happens when trying to issue $ rm *P* or the like: ...
7
votes
3answers
2k views

List file range with UNIX wildcards

Say for example I have the following files in my working directory: mjk0001.fits, mjk0002.fits, ... numerically increasing all the way to mjk9999.fits. Is there a way to use UNIX wildcards to list or ...
0
votes
2answers
409 views

Writing Unix script (bash) that creates a directory in the location specified at the command line

I currently have a Unix script (written in bash) that executes several commands to modify a group of files, which I specify with an flist containing their paths. The general idea of the script is to ...
0
votes
2answers
398 views

Deleting line from file using SED in MultiUser Case

I have a scenario where multiple users are connected to a server using SSH. I have a file which is read and written by all the users. The file contains numbers like this - 14554 14887 23451 15135 ...
2
votes
2answers
441 views

Bash change user info (like usermod) but without root privileges

I am writing a small GUI program for a user to edit their own account. You cannot run usermod as a regular user, I am looking for that kind of functionality. Changing a users fullname is the most ...
1
vote
1answer
562 views

Trap Ctrl+C and repeat the while loop in Bash

I was trying to trap CtrlC or CtrlZ and clear the screen and repeat the loop without exiting – it's working but I need to press Enter to repeat the loop. #!/bin/bash trap 'clear' 2 20 while : do ...
1
vote
2answers
249 views

Remove X number of characters from command STDOUT

I'm running an application that is outputing lines, piping to GREP to select only specific lines, but want to remove the first X characters which are worthless. Specifically: varnishlog | grep Hash ...
0
votes
1answer
38 views

On ec2 how do I use navigation shortcut keys?

Whenever I ssh to ec2 I notice that ctr+a (beginning of line), ctrl+e, and other navigation keys do not work in terminal. Is there a way to set up my ec2 terminal so that I can use these navigation ...
1
vote
1answer
61 views

Bash and double echo

I have the following code. In all cases I'm expecting to get 1 1. Could someone explain why I do not get the expected output in the first case? The question seems to be very simple and I think I'm ...
0
votes
1answer
62 views

Tab key prints an “ i ” to the console instead of executing tab complete

I have been using Linux for 27 hours now and I am just now getting aquainted with the command line interface. In my instruction, tab complete should execute the remainder of a directory name such as ...
2
votes
1answer
1k views

How to log bash command with its output?

I want the actual command line be logged together with its output. I routinely execute important commands like this: PERL5LIB=${PERL5LIB}:/something/extra my-command.pl many arguments which I want ...
6
votes
3answers
379 views

How can I easily see the man page for builtin shell commands?

If I see a command in a script that I don't know and I type (for example) man pushd or man umask I see the man page for builtin commands. I know that I can do man bash and scroll to find the help for ...
0
votes
1answer
2k views

Remove all symbolic links of files in one command

I want to remove all the symbolic links of files. I have a directory structure like /usr/local/instantclient/11.2.0.3 which contains lots of files and i have symbolic links of these files in ...
2
votes
2answers
349 views

ssh backspace deletes one character instead of two (utf-8 symbols)

Im accessing a remote computer using ssh and running a bash command to input symbols using standard input stream: read test;echo $test It's ok to input english letters and use backspace to ...
1
vote
1answer
160 views

How can i set the flags with gentoo prefix

I have install the LFS system , after that I tried to install the gentoo prefix on my system. But it comes error: I'm going to check for some variables in your environment now: it appears ...
0
votes
1answer
298 views

output of `svn status -uq` has no newlines in script

function runstatus { echo "SVN Status -uq:" echo status=$(svn status -uq) echo $status echo $bigline } This prints something like: SVN Status -uq: rd_backup ...
0
votes
2answers
991 views

Bash script fails with “syntax error in conditional expression”

I'm new to bash scripting, and I just want to do a simple little thing, but everything I read online seems to not work for me! So I have this script here: #!/bin/bash if [[ $1 = "32"]] then ...
1
vote
1answer
77 views

Writing a script to tell which users are currently typing? [closed]

I'm working on a lab for a cyber-security class and need to find out when certain users are communicating with each other (through named pipes). The users use: python gameProgram.py And then that ...
0
votes
2answers
569 views

permanent powertop changes with systemctl

I have got a .sh-script, trying to make powertop changes permanent. 'auto' > '/sys/bus/pci/devices/0000:00:02.1/power/control'; the commands in this .sh-script are all of this type. I have a ...
1
vote
1answer
112 views

How to prepend contents of a file to another

This question relates to the already asked question How to add text to beginning of file The answer suggested by Dennis Williamson does the job: echo 'task goes here' | cat - todo.txt > temp ...
1
vote
3answers
2k views

How to run a script at boot time for normal user?

I want to run a bash script at boot time in CentOS 6. I added the script in /etc/init.d/ directory but all these script are run by root. I want to run script for any user.
0
votes
1answer
470 views

cygwin AtlGr+pipe key not working as a pipe but as a split vertical bar

In cygwin with Windows 7, when I type AltGr+backtick key, I expect a | pipe sign to be typed, but instead I get a pipe that is split in the middle ¦, which won't act as a pipe sign in cygwin. How can ...
0
votes
1answer
268 views

sfdisk partition size in bytes

Kind of homework related so further reading is always appreciated! Using sfdisk I have to specify the size of certain partitions in bytes. For this I used sfdisk -lub /dev/sdd Which lists the ...
0
votes
1answer
329 views

Unable to run test.sh file through project.php inside /var/www/

test.sh's path is /var/www/proj/test.sh, and project.php is inside /var/www/ and my test.sh uses and creates some .txt files. when i execute test.sh through terminal it works fine, but when I run ...
0
votes
1answer
205 views

Having Trouble Sending Arguments To Mintty/Cygwin

Simply put, I would like to have a shortcut on Windows which can open up a terminal window just like clicking the Cygwin shortcut normally does, but in a different location from the default. The ...
-2
votes
2answers
664 views

How to run apache server if it not already running

I wonder if it is possible to check whether or not apache2 is running. If it is not running I want to execute it using shellscript Currently I have added a function which I named run_apache which ...
2
votes
1answer
129 views

Suppress (or quiet) the output of bash: “Hit any key to close this window…”

Typically when I invoke an GUI application in vim, I get a command prompt that awaits for my response: shell returned 1 Hit any key to close this window... How can I not make this prompt to show ...
0
votes
1answer
697 views

gVim does not source .bashrc, .bash_profile, or .profile from non-interactive non-login shell

I have the following on my .vimrc set shell=C:/cygwin/bin/bash set shellcmdflag=-c set shellxquote=\" So the shell I am using is non-interactive and non-login. I thought that non-login shells ...
0
votes
1answer
206 views

How close to death is my Linux hard drive [duplicate]

I want to test my hard disk that is on opensuse 12.2 - update see some results below I have installed S.M.A.R.T. How would you start the tests? note: can I run a single test that runs all the ...
5
votes
2answers
8k views

bash - Sending simulated keystrokes

I've recently been trying to write a script that can be used to automate my c++ program in bash. If you know AutoIt, I can simply show you an example of what I am trying to do: send("1{enter}") or ...
6
votes
3answers
14k views

On Linux, how can I find all files that contain a string and delete them?

I want to delete all files that contain the string foo. How can I do this using bash in Linux?
0
votes
2answers
458 views

Script to auto execute creation of ssh tunnel

I'm a CS student, and still learning a lot of these things, and so please bear with me if I don't have a full grasp on what I'm trying here. I'm on a Mac, connecting to a linux machine. I can set up ...
5
votes
1answer
363 views

TMUX: Configure length of titles

I have tmux configured to show my current working directory for each window (it gets this from bash) The problem is, sometimes the directory names get too long and it takes up a lot of space. In ...
0
votes
0answers
22 views

Loop through folder with higher space usage in shell? [duplicate]

I would like to create an script where give me a report of which folders have the higher usage space and keep doing that until there's no folder anymore. Today I do this manually, with: sudo du -h ...
0
votes
1answer
806 views

how do I preserve export PATH?

How can I make ssh admin@nas command work if command is in /opt/bin? On my QNAP NAS File /root/.ssh/rc: echo "old path is $PATH" export PATH=/opt/bin:/opt/sbin:$PATH echo "new path is $PATH" on my ...
1
vote
2answers
93 views

Newlines while saving variable to file - bash

I have mulitiple ip adresses in a variable. ActiveIPs= 192.168.0.1 192.168.0.2 192.168.0.3 I want to save them to a file like this 192.168.0.1 192.168.0.2 192.168.0.3 how do i do this?
0
votes
1answer
72 views

How to make an alias and work in sh for all users (not in bash)?

My question maybe is silly, but how can I make an alias so as to work in sh for all users? I know that I can put an alias, let say this one: alias ls='ls -l' in /etc/bash.bashrc so as to work in ...
0
votes
0answers
12 views

Bash history lost [duplicate]

My bash history in cygwin is lost between two consecutive shells. Here are the outputs of some commands that might help to understand the issue: set -o | grep history history on $ grep -i ...
1
vote
1answer
47 views

How to print a bash history command and append it to a file?

You can print a command with: !2500:p But how do I append that command to a file? I thought: !2500:p >> .bashrc But that just prints everything including the ">> .bashrc" to stdout.
2
votes
4answers
8k views

No bashrc file in my home directory

Here is what I noted down from my lecture: Find file .bashrc in your home directory do vi .bashrc When you put an application folder somewhere, make sure that its address is in the path variable. ...
5
votes
2answers
2k views

How to persist bash history?

I don't know if this is expected, but my history is not saved across sessions. This is to say, if I close the window, then when I open it again, the history is empty. How can I persist it across ...
0
votes
2answers
228 views

Why does my ssh session terminate immediately?

I have a debian machine, where I have difficulties to log into via ssh. Executing commands on the server over ssh is no problem -- just I get no prompt, but the connection is terminated again: > ...
2
votes
2answers
73 views

How do I investigate commands being run when changing directories?

I see “awk”, “find”, “sed”, and “which” momentarily appear in my Terminal window's title when changing directories.  (And not all of these always appear and there could be some I'm missing; I imagine ...
2
votes
1answer
128 views

Difference between / and // directories in bash OSX

I was working in the bash terminal on my system (OSX 10.8.3 / bash version 3.2.48(1)-release (x86_64-apple-darwin12)) and I accidentally typed "cd //" instead of "cd /" to get back to the root ...
2
votes
1answer
314 views

copied chroot jail directory cant be chrooted

I am developing a package so when users login through ssh they are forwarded to a chroot jail. The jail directory is created via makejail program on building process. But when the jail package copy ...
0
votes
1answer
147 views

bash tab-completion list below prompt

Whenever I use tab-completion, the list of possibilities is displayed and the prompt is duplicated below (| indicates the final cursor position): $ vim ~/.<TAB> ./ ../ .bashrc .vimrc $ ...
0
votes
3answers
951 views

How do you install Bash or Bash utilities on Windows? [duplicate]

How can I install Bash for Windows so that I can use its utilities, such as grep, vim, and gcc with minimal amount of work in editing the environment variables to include them all. I'd like to do this ...
2
votes
1answer
157 views

Opening a Terminal for the current bash script, if it wasn't started in one

How can I get a script to re-launch itself in a Terminal window if it wasn't started in one? Based on this question, I've tried, in a file called testterm marked executable: #! /bin/sh if [ -t 0 ]; ...
0
votes
1answer
72 views

Colorize ls-output by filetype [duplicate]

Every once in a while I have to list some files (~20-50) in Bash on Linux || Mac. These files are from four different file types. ls nand2tetris/myChips/ And16.**hdl** And16.**cmp** ...