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

learn more… | top users | synonyms

0
votes
2answers
148 views

What files does the mac terminal load first?

A while ago I installed a program called "j" for the terminal. It was supposed to make things simpler. However, after a while of using it I decided I didn't really need it and trashed it. Now ever ...
1
vote
1answer
868 views

what is the proper SSH command for logging into Github

After following the standard roadmaps to setup a github environment, I inmediatley encounter errors. I like to see these clarified. I have put a more detailed question below after the code garble that ...
1
vote
1answer
69 views

Cannot find what exports CDPATH

I made the mistake of putting CDPATH into my .profile file just to see if it would slightly boost my productivity but found that sometimes it would cd to directories that I didn't want it to (I would ...
0
votes
1answer
533 views

Linux: page-up key to browse through history

In some linux systems, when I write the beginning characters of a command and press page-up, I can browse through the latest similar commands saved in the history file. However, I found that this ...
5
votes
1answer
272 views

Bash auto-completion of variables adds additional white space at the end

when I perform an auto-completion of a bash variable an additional white space is added at the end. $FO[TAB] -> $FOO" " I added the quotes in order to denote the white space. The problem is ...
9
votes
5answers
7k views

bash execution time in milliseconds (mac osx user)

I've checked this , but the solution provided did not work for me. Using date I can get the execution time in seconds: T="$(date +%s)" #some work here T="$(($(date +%s)-T))" echo "execution time ...
1
vote
1answer
77 views

How interact in for with bash?

I know this must be sound a weird question, but for me, that always developed in C, C++ and Java (and now in bash) seems more weird tough. I'm trying to check if md5 and filename from two list (one ...
0
votes
3answers
386 views

Is there any way to encapsulate bash functions?

I'm writing a simple script script.bash that is supposed to export some variables environment, to use it in my current session I have to source it $ . script.bash script.bash function fun1() { ...
2
votes
2answers
86 views

Running cp -r ~/.ipython ~/some/path/.ipython a second time creates ~/some/path/.ipython/.ipython. How to prevent that?

I am using a script to copy directories to a specified location. When I run cp -r ~/.ipython ~/some/path/.ipython the .ipython dir is copied as expected to the specified location. But when I run this ...
0
votes
1answer
265 views

sed command working in command line but not in script [closed]

I have a script with the follow code: find . -name "*.html" -print0 | while IFS= read -r -d '' n; do sed -i -r 's/<font ...
0
votes
1answer
153 views

Why the command substitution in the crontab job doesn't work?

crontab -l: * * * * * /Users/michel/Desktop/myScript.sh myScript.sh: #!/bin/bash /usr/local/bin/growlnotify -t 'Fact' -m "$(/Users/michel/Desktop/anotherScript.sh data.txt)" -n 'myApp' it ...
1
vote
2answers
99 views

How do I show the real current directory in my bash prompt, not the symlink

I use the default value of PS1 shipped with Ubuntu: \[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$ which is ok 90% of the time. However, when I cd to a symlink "directory" the ...
3
votes
1answer
59 views

Linux History Display Dates

I added date and time to my linux history with this command: export HISTTIMEFORMAT='%F %T ' When I actually go to view my history anything that I didn't actually do today seems to pick a time that ...
1
vote
2answers
431 views

How to save echo result into a variable?

I have this output from a s3cmd ls --list-md5 command. 2013-05-22 12:20 1965154 41eae9b40d23de2f02bf07635870f6d0 ...
3
votes
2answers
177 views

Found a script on my cron.monthly, i am wondering what's it doing?

I am new to bash-programming, sorry if this might be a kind of stupid question. I found a script on my server and i am trying to understand every line: #!/bin/sh # # man-db cron weekly set -e if ! ...
1
vote
3answers
461 views

rsync: Can it transfer files ignoring size (comparing only timestamp and name)?

Can rsync compare/copy based on mod date and filename alone, ignoring file size? Context: I'm trying to implement a two-stage backup using rsync. The first stage is onsite, and I have a bash rsync ...
2
votes
1answer
46 views

What is the difference between bash and -bash?

What is the difference between bash and -bash. When I execute echo $0, it returns bash on one machine and -bash on the other machine. What is the difference between them?
3
votes
1answer
167 views

How to `rm *`, an actual file named “*”? [duplicate]

I don't know how this happened, but I have a broken symlink in my home directory named *. I was just about to rm *, and then I had a facepalm moment. Should I rm \*? rm '*'? Something else? Backing up ...
0
votes
1answer
200 views

What is the proper way to shell script a start / stop process that is triggered by another process?

Program 1 runs irregularly, and crashes program 2, which then crashes program 1. I'm not able to find the proper way to make program 2 stop when program 1 is initiated, and then restart program 2 ...
8
votes
1answer
8k views

How to change the resolution of the Bash for a Debian VM?

I'm trying to learn how to use Linux with a Debian 7 VM that has no GUI. The 640x400 window I'm working in feels a little constricting and would like to make it bigger, say 1024x768. How can I do ...
0
votes
1answer
506 views

Locking a GNU-screen session after x minutes of non-use on Linux

I have a couple of services running in a GNU-screen session on top of Bash. Because one of the services contain sensitive data I have to constantly either close the terminal completely or lock the ...
2
votes
2answers
224 views

How to recover bash output of an already closed window?

I have run a specific program in a bash terminal and I closed it by mistake before reading its output. Is it possible to recover the information that was sent to the stdout by taking a look at some ...
4
votes
4answers
3k views

How to send an `xmessage` as root remotely to regular user logged in with 'x' session?

I'm using BASH on the command line, logged into another user's PC as root, via SSH. I wish to send the user currently logged in running an X-session, a popup message, but this is the result: ...
2
votes
1answer
365 views

gnome-terminal - color palette

I'm trying to assign color palette on my gnome-terminal but it doesn't change at all... any clue? Screenshot > http://i.imgur.com/MXXhoOo.jpg Aditional info: Fedora 18 64bits (shiny new) GNOME ...
1
vote
2answers
250 views

Why echo $(crontab -l) outputs current working directory listing and only then the content of crontab file itself?

So if cwd is the /tmp now: crontab -l > #min hour day mon dow command > * * * * * /usr/local/bin/growlnotify -t 'helloTitle' -m 'helloMessage' -n 'myApp' -sw but: echo $(crontab -l) > ...
2
votes
1answer
2k views

Remove file extension in OS X using Terminal

Problem: I have some 200+ files named something in line with "DSC01852.JPG.jpg". I would like to remove the file extension so the result becomes "DSC01852.JPG". Any suggestions? I looked at the mv ...
0
votes
1answer
260 views

Merge three files into one in a bash script

I have a series of folders containing three files that I want to concatenate as part of a script. The three files are named file.html1 file.html2 file.html3. I want to concatenate them into file.html ...
0
votes
0answers
35 views

what does “cd //” do in linux? [duplicate]

I'm running Ubuntu 12.04 and in bash, when I type cd // I get to what looks like root. However, the pwd command yields //. I can create files, and everything seems to behave like normal bash, just ...
2
votes
2answers
2k views

How to convert ASCII character to integer in bash?

I'm parsing an ntpq output to pass its contents to our database via console utility. The first element is a one character substring containing status of the remote. It can be "*", "+", "o", "#" etc. ...
2
votes
2answers
156 views

Difference between almost the same directory commands

Is there any difference between these (almost the same) directory commands? 1. cd 2. cd ~ 3. cd ~/ I tried it in my shell, and they all lead to the home directory. Is there any possible scenario ...
1
vote
0answers
587 views

File shows different size after copying to another directory

I used cp -rP <dir name> <new dir name> to copy the contents of a directory, including permissions etc from one dir to another. The odd thing is, either du is giving me some strange ...
2
votes
1answer
529 views

How do you remove nested empty directories using a Bash script on Linux?

I want to be able to run a script that will remove all my empty directories. The problem is some of them are nested, i.e. directories that only have empty directories in them, so the script needs to ...
12
votes
2answers
719 views

Why does redirecting the output of a file to itself produce a blank file?

Why does redirecting the output of a file to itself produce a blank file? Stated in Bash, why do less foo.txt > foo.txt and fold foo.txt > foo.txt produce an empty foo.txt? Since an ...
0
votes
2answers
2k views

Replacing a dot with an underscore in a file using sed

I was trying to edit the output of a file using sed. The contents of file are cat /tmp/Group_RM t.p@k.p t.m@k.k I was trying to get the output as: cat /tmp/Group_RM t_p@k_p t_m@k_k I tried the ...
4
votes
1answer
401 views

How to execute bash script without password?

I need to execute the script after system boot. For example: (sleep 5 && (sudo dhcpcd wlp4s0)) What I need: Executing the script. What I have: [sudo] password for eugene: I has been edited ...
1
vote
1answer
72 views

Pass result of the command to exec

I have a kind of "bash newbie" question: how do I pass the result output of one command to exec. The result of the first command is the name of other command, so exec should be able to execute it.
65
votes
6answers
4k views

How do I perform commands in another folder, without repeating the folder path?

Is there a clever way to do copy and move operations or a command to duplicate a file, without having to do a cd, then mv after, at the same folder? For example, I have to run the following: mv ...
3
votes
4answers
6k views

SSH remote command no reading all environment variables

I have declared some "PATH" variables in the ".bashrc" file of a remote machine. When I login to the remote machine, all these "PATH" variables work fine. But when I do a "ssh user@remote env", the ...
1
vote
1answer
559 views

How do I install 'z' file directory jumper on linux?

I'm attempting to install this and running into issues. I am supposed to add a line to the ".bashrc" file? Where in the file? the bottom? the top? somewhere in the if statement? do I make it an alias? ...
0
votes
0answers
11 views

Going back to a stopped job [duplicate]

wim@wim-zenbook:~$ ipython Python 2.7.4 (default, Apr 19 2013, 18:28:01) Type "copyright", "credits" or "license" for more information. IPython 0.13.2 -- An enhanced Interactive Python. ? ...
2
votes
4answers
4k views

Is it possible to run software as a different user under OS X Mountain Lion?

I've been trying to run apps as a different user. Attempt 1 sudo -u otheruser open /Applications/TextEdit.app launches the app but it uses the current user, not otheruser. Attempt 2 login username ...
2
votes
1answer
3k views

Where to store bash scripts that all users may execute on Debian?

I have many bash scripts on my server, that all users may use. but it seems the location /usr/local/sbin is not the best place. I don't want to use the home directory of the users, cause ...
0
votes
2answers
4k views

Add /usr/local/sbin to the PATH of a user [duplicate]

if I type echo $PATH I only get /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games how can I add /usr/local/sbin to the path, so it is already there the next time? (I use debian ...
5
votes
3answers
3k views

Is it possible to put foreground process into background without suspending (control +z)?

I am running an application which receives TCP and UDP packets and therefore cannot be suspended. I intially ran 3 processes of the same application, with different arguments, in background mode using ...
0
votes
1answer
117 views

Prevent users from being able to pipe output to another users terminal?

So currently on this server if two people are logged into the same server, you can do something like: -bash-4.1$ cat /dev/urandom | write username It will print a bunch of junk to their terminal. I ...
0
votes
1answer
88 views

rm the current directory you are in and issues surrounding it

If I cd to a directory, is there a quick way to delete the directory I am in and move to the top directory? Usually I cd to a directory, ls it and then cd .. then delete the folder. I want to be able ...
0
votes
1answer
73 views

Use a modern locale, but retain asciibetical sorting?

I bought a new laptop (an Ideapad Yoga), and put Linux Mint on it. Everything seems to be working well, but Mint's default LOCALE settings for my language choice (en-CA... not sure why CA when I'm in ...
3
votes
3answers
2k views

Prepend prefix in tar

I currently do in a shellscript very inefficiently: cp -a $MYPATH /tmp/$VERSION cd /tmp tar cjf archive.tar.bz2 $VERSION I want everything to be contained in the directory called $VERSION - is ...
1
vote
2answers
2k views

Throttle CPU based on Temperature? - Ubuntu

I was running some programs on my Ubuntu machine that use max CPU power for extended periods of time. This causes the computer to overheat. Could someone suggest a good program that will throttle ...
0
votes
1answer
54 views

Modify Several Plist Using a Script

defaults read /New.plist itemName the Output Will Be Some Thing Like "Software" but i want the new Data to be updated for the key as "Software Old Version" the problem is i have to modify several ...