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

learn more… | top users | synonyms

8
votes
7answers
5k views

Replace Symbolic Links with Files

Is there an easy way to replace all symbolic links with the file they link to?
0
votes
1answer
19 views

Windows batch equivalent of bash's set -e

Is there a Windows batch equivalent to bash's set -e, which causes the shell to exit immediately if a command fails with nonzero exit status (except in places where it's expected like in an if ...
1
vote
2answers
27 views

Restarting process in CentOS if server restarts

I have a VPS with some Java applications (made with "Play Framework") running on ports 9000, 9001, 9002 and 9003. VPS Provider (iPage) happens to reboot servers unexpectedly from time to time, leaving ...
1
vote
2answers
37 views

What does ./ mean in Unix/Linux [duplicate]

This might look wrong, but I know that using ./ you are basically "BASH"ing your scripts in Linux/Unix environment. For Windows users, this is same as running an .exe file from command prompt. ...
0
votes
0answers
7 views

Kill browser tabs with Bash from younger to older

Hello i want to kill tabs from a browser(ex. chromium) by order from youngest to oldest. I used pkill -f -n -9 chromium but i want to use it in a while iteration with comparison to pkill's return ...
0
votes
0answers
20 views

remove spurious ending spaces when copy pasting from emacs console mode?

I'm not really sure where this comes from but it's really annoying: Using emacs in console mode, and when I want to copy from emacs and paste to another application (possibily another term) I often ...
1
vote
0answers
11 views

Centos Kickstart Multiline Cat

I have a serious of multiline cat commands in a kickstart file under the %Post section. For some reason all the lines get written to the same file. Example: %post --interpreter /bin/bash ...
0
votes
0answers
16 views

How is a basic daemon made on OSX?

I have an OSX system that I'd love to have some daemons set up on that will automate the updating of all of my console utilities. How would I go about creating and running such daemons? I'd also like ...
1
vote
1answer
379 views

Upgrading Chromium OS to Chrome OS mount error

I'm trying to upgrade Chromium OS to Chrome OS with http://goo.gl/4suhf. Unfortunately, when running this script (inside Chromium OS), it says: wget stuff unpacking zipfile RootFS Start: 286720 ...
0
votes
1answer
15 views

Delete a file inside multiple ZIP archives on the OS X command line

I'm trying to delete files with specific extensions from multiple zip archives. For example I want to delete all .html files contained in the zip archives in the current path so I have tried this: ...
0
votes
0answers
11 views

cp: fts_open: No such file or directory / Why?

I have following bash script: #!/bin/bash echo "This script will copy all JPG files inside directory '~/temp/merged':"; pwd; read -r -p "Please confirm, that you want to copy all JPG files [y/N]" ...
2
votes
2answers
67 views

List folders in Linux which can only be seen if accessed

Maybe it is a amateur question but here it goes: At the university we have a folder /vol. This folder is absolutely empty until you "cd" into a directory which exist there. E.g. "cd ...
1
vote
3answers
2k views

Shell script bash: Moving file iterate based on month

I have very little knowledge about shell scripts, but unfortunately I have to write one. I want to ask about bash script iteration moving files, I need to move log files sorted by month which will be ...
0
votes
0answers
10 views

gfortran not working on my Mac OS X

I tried running gfortran on my Mac OS X, but it wouldn't work. When typing gfortran in the terminal I got the error -bash: gfortran: command not found. So I thought maybe my installation was not ...
19
votes
3answers
4k views

How can I make the bash backtick operator keep newlines in output?

Is there a way to make bash not eat newlines in the backtick substitution? For example: var=`echo line one && echo line two` echo $var line one line two What I want is var=`echo line one ...
106
votes
8answers
116k views

Where does $PATH get set in OS X 10.6 Snow Leopard?

I type echo $PATH on the command line and get ...
-1
votes
1answer
47 views

Can't understand loops :( [on hold]

I'm trying to understand better the while and until loops, can someone help me with this example? #!/bin/bash # Listing the planets. for planet in Mercury Venus Earth Mars Jupiter Saturn Uranus ...
3
votes
2answers
88 views

Removing “.” while standing on it

While toying with the file system, I tried the following: mkdir a cd a rmdir . Which results in: rmdir: failed to remove ‘.’: Invalid argument Ok, Mr. rmdir, let me outsmart you: rmdir ../a ...
0
votes
2answers
72 views

Why doesn't xargs on find work with a series of commands using pushd and popd to walk a directory subtree?

On a Linux Centos 4 machine, I am trying to create a simple bash command line to walk a directory structure below an arbitrary current directory and in each subdirectory touch a file, list the ...
5
votes
1answer
624 views

Meaning of . and .. directories in linux [duplicate]

When display hidden file and directory in terminal using ls -la it show two directory i.e. . and .. and when list the content of dot(.) directory it contain all file and directories that is in it's ...
0
votes
1answer
29 views

Combination of Echo and >> operator command

I was learning how to configure Django on OpenShift and got stuck with following commands. Can anyone help me to find out what operation is performed by these commands here and what can be its ...
5
votes
3answers
8k views

How to remove all files starting with a certain string in Linux

I need to find all files starting with the name NAME in a directory tree and remove all these files using one shell command.
-4
votes
1answer
28 views

Shell script for going through files and deleting or compressing them

List, one at a time, all files larger than 100K in the /home/username directory tree. Give the user the option to delete or compress the file, then proceed to show the next one. Write to a logfile ...
0
votes
1answer
29 views

Linux find files in subdirectories by extension (.txz) then move them to specified directory using regular expressions

I have mirrored a directory from a server with a large number of sub directories, each of which contain a .txz package and the usual .txt and descriptor files. What I would like to do is the ...
0
votes
1answer
32 views

is there a way i can either insert a character into a line or substitute and arbitrary character with itself plus some other carachter(s) in sed?

like say i have a string of numbers that constitute a phone number and are like so ########## and i want to format them like : ###-###-#### insert only puts in new lines, and i dont know how to ...
1
vote
1answer
26 views

Good way to bookmark/navigate relative directory paths?

I work on a linux system with bash 4.x where I frequently find myself navigating different copies of very deep (and large) file directory structures. However, in reality I only need to access a ...
1
vote
2answers
648 views

Increase the space between lines in vim

I think the title says it all. I've done my homework and the only command that I found was: :set linespace=3 but it doesn't seem to work, neither on the Mac nor in Linux. Edit: In Mac OSX you can ...
0
votes
1answer
22 views

Awk script to run a command based on condition using 'if'

I have a piece of code here that basically takes a file called 'srcip' (which is just a list of IP addresses) and compares it to my '~/db' file which is just a tab delimited IP HOSTNAME database of ...
0
votes
2answers
30 views

Alter output of every command

I'd like to know if there's any way of altering output of every command I execute in terminal. The purpose is to make the output formated for my markdown howto's. E.g. ls -la .*z #>-rw-r--r-- 1 ...
32
votes
6answers
40k views

Mac OS X keyboard shortcuts for terminal

After googling for some Mac OS X terminal shortcuts, I wanted to find how can I go back characters on a line on the terminal or words or similar. I found ALT + B but it does not work. Do you know ...
0
votes
2answers
29 views

Perform Terminal Commands Without Opening the Terminal - Linux

Is there anyway, within Linux, to open a terminal or perform a terminal command (such as executing a script) without actually opening the terminal window. What i'd like to do is be able to execute a ...
0
votes
2answers
27 views

linux cat into file including exiting code all from copy+paste

Can I print out a code to STDOUT that would mimic the behavior of Ctrl+c inside cat? E.g. I would like my script to print out the cat command followed by the content of the file like this: cat > ...
0
votes
0answers
6 views

Is “Lynx: can't access startfile” normal when I'm looking for broken links? I'm kinda desperate

I'm doing a script in bash for checking broken links, is it normal that the dialogue "Lynx: Can't access startfile" appears when I run the script? This is my code so far: #!/bin/bash ...
1
vote
1answer
16 views

How do I insert a constantly changing (dynamic) string from a text document into .conkyrc as an image path

I want to change the Clementine album art with each song. Essentially, I am trying to insert an image path in Conky that changes every few seconds. I have a script clementine.sh that runs every 5 ...
1
vote
4answers
42 views

Grep to filter gigantic CSV file

I'm dealing with a CSV file that contains over 2 million lines. Quite a big one. I need to use grep (or any better way) to retrieve the entire row if the value of the second column matches 'jpn' or ...
1
vote
1answer
23 views

echo “something” > file not working when sh script is being executed by remote PHP server

I've got a web-server with my hardcoded webpanel for Source server management and I've got my VPS on CentOS which doesn't really want to execute sh script when asked from remote server. Web-server ...
1
vote
2answers
182 views

Why is “source <(cmd)” working but not “$(cmd)”

I want to have a script to call with params which adds some aliases to my current shell. The aliases have to be builded in respect to the calling parameters and the current directory from where I ...
0
votes
1answer
24 views

Creating a macro with .sh

so I would like to write a script that will be used in the following way. ./MakeMacro 1 The basic form of the script looks like this: #!/bin/sh ...
0
votes
1answer
49 views

Temporarily switch Java version in bash script- Ubuntu Linux

I'm using the Java keytool as part of a larger bash script. I need to pass in a password to create a keystore, so used the command keytool -importkeystore -deststorepass:file ${somefile}. This ...
0
votes
4answers
19 views

How do I close stdin in a shell script?

I have a misbehaving program that I need to call from my script. It exits as soon as it sees something on stdin. Is there a way to close stdin?
2
votes
2answers
58 views

what is `ssh-agent bin/bash` and why I have to `ssh-add` everytime

I have to run the following commands each time I restart: ssh-agent /bin/bash ssh-add ~/.ssh/key_rsa First question is why is /bin/bash necessary and what it is used for? Second, Is it ok I run ...
0
votes
2answers
25 views

How can I make bash cut and paste to the X selection?

In bash under an xterm, how can I get Ctrl-k / Ctrl-y to cut and paste to the X selection?
1
vote
2answers
29 views

reverse print without trailing

I have a bash file calling a dns zone and have piped out the fqdn which I need to output in reverse. The snippet below does that fine except I get a trialing . at the end which I don't want creating ...
3
votes
2answers
3k views

OSX 'open with' bash script

I've got a bash script, potentially many of them in fact, which I'd like to be able to open files in OSX's finder with. It's a really, really simple concept but for some reason bash scripts are ...
1
vote
1answer
19 views

How to split and recombine stdout pipe in bash?

I am parsing text on the command line. How can I take the output of one command and use it in two places in the next command? some_command | head -n $( awk '/search_term/ {print FNR} ...
2
votes
1answer
48 views

Timer running under bash script in dialog window

The following bash script is an example on how to use the dialog command. This script runs a progress bar (and displays the process upgrade). What is missing in the dialog is a time clock - that ...
0
votes
1answer
26 views

Why do i get a file named history in each folder in bash?

For some reason I get a bash history file in each and every folder where I issue any command. The file is called history rather than the normal .bash_history. My .bash_profile has the following that ...
0
votes
1answer
2k views

“Reset” colors of terminal after ssh exit/logout

When I ssh into a remote server, I like the colors of the terminal to change. I use setterm on my remote ~/.bashrc file to get this done. However, when I exit, the terminal colors are not reset to the ...
1
vote
1answer
37 views

How to view two dialog boxes on the linux console, running on the same time?

I want to view on the Linux console two dialog windows on the same time. I want a window that views the progress BAR, and the a second tailbox that view the logs are running. The problem is that the ...
1
vote
1answer
31 views

Change auto mount directory of SD card

I want to write a bash script to backup a certain directory, but only to a particular SD card. I want the script to have a way to check if this particular SD card is inserted. I run Lubuntu, which ...