1
vote
1answer
27 views

Global variable for every script

I want to declare a variable in such way that every script can access and alter its value. I have written a script that set the value of a variable called flag on exit and I am using a crontab entry ...
3
votes
1answer
181 views

How do I fill my password automatically from .bash_profile when running command as sudo?

I know I could just put something like sudo mypassword in my .bash_profile, but I don't want to run every command as root. I want password to autofill under following circumstances: only the ...
0
votes
0answers
33 views

X11 Path Issues and Confusion for Installed Packages

I am using GMT (generic mapping tools) and SAC (Seismic Analysis Code), and each use X11 (or XQuartz on 10.9.4 Mavericks) to display graphics. When I want to display postscript using ghostview, I get ...
0
votes
1answer
83 views

Writing a Bash script to run and end at specific times

I'd like to create a script that will do the following. Start at a given time during the day and end at another given time. So for example, I have a program I'd like to test, so my script would be ...
8
votes
3answers
584 views

Creating a Bash script that will execute a program and if it exits without crashing, will run it again

I'd like to know the easiest way of creating a bash script that will run an app in MacOSX (it's a UNIX based system so I assumed this was the right place). wait for the program to exit. If the exit ...
1
vote
1answer
48 views

Control + L not clearing screen

When I try to clear my terminal screen on OSX: computer@ ~ () $ ^L And when I hit Enter after that it just shows: -bash: : command not found Any ideas on how this happens? My .bash_profile, ...
3
votes
2answers
36 views

How can I list the info for an array of /dev/disks using bash expansion or substitution?

I want the output of: diskutil list; diskutil info [multiple devices] Without having to do: diskutil info disk0; diskutil info disk0s1; diskutil info disk1 ...etc For example, with many builtin ...
0
votes
0answers
26 views

[Solved]man crashes on OS X after upgrading bash and its manpages

Bash on OS X is always so old that I finally decided to compile a never(4.3.18) one and simply override and replace the old one. Here are the configure flags I used: ./configure --prefix=/ ...
2
votes
1answer
50 views

Running a command without ./

I am trying to understand something that might be very simple for a lot of you but is quite puzzling from me as a daily Windows user. I am following the docker installation on Mac OS X. One of the ...
0
votes
4answers
137 views

Mass mv on files and changing filenames [duplicate]

I want to change these filenames download (19).download ... download (27).download to download (19).html ... download (27).html I run unsuccessfully mv *.download *.html usage: mv [-f | -i | ...
8
votes
3answers
655 views

Why are interactive shells on OSX login shells by default?

In Linux and, to my knowledge, all Unix systems, terminal emulators run interactive, non-login shells by default. This means that, for bash, the started shell will: When an interactive shell that ...
1
vote
1answer
84 views

What version of bash am I running

I tried to change default bash on OS X Mavericks, Installed new bash trough brew, run chsh -s /usr/local/bin/bash, went to "Users and group" made sure that Login shell for my login points to the ...
0
votes
1answer
24 views

Unrecognized Type: for length of date string [closed]

I am getting current date and checking for length of date if non-zero then perform some action. now=$(date) echo "$now" if [[ -n "$now" ]]; then echo "not empty" fi Prints this to console- Mon ...
1
vote
1answer
50 views

Automatically copy PDF.plugin to Chromium.app

I'm using Chromatic.app to update my Chromium.app recently. I'd like to use Chrome.app's PDF.plugin in Chromium.app. Therefore I need to copy PDF.plugin to the following directory: ...
0
votes
2answers
98 views

Why mkdir -p /Local/Foo/Bar/Wah not work but cd /Local and mkdir -p Foo/Bar/Wah works? [closed]

I am trying to create a local folder in my local development machine, on Mac OS X Mountain Lion, so I did: sudo mkdir /Local sudo chmod 777 /Local mkdir -p /Local/Foo/Bar/Wah (note that last line ...
3
votes
1answer
44 views

**/ not working with a mounted volume

I'm trying to recursively extract a set of .jpgs from a mounted volume using SMB1, to a folder on my computer. Here's what I've got: cp -a **/97*.jpg /Users/.../All_Covers This works as long as my ...
2
votes
4answers
80 views

How to edit/delete a .dot_file on mac without using Terminal

When I start Terminal I can not control it. It starts executing an endless loop repeating that some alias does not exist. Because of this I am not able to edit this file using a program such as vim. ...
0
votes
1answer
40 views

How to create an alias for opening a directory on Mac

Trying to create an alias hello. After typing hello in Terminal, then vi opens hello_folder. Now, this code returns: $ hello -bash: hello: command not found 1 #!/bin/bash 2 cd ~/Documents/ ...
0
votes
2answers
754 views

Rename file in Mac OS Terminal using Regex

Hundreds of images need to be renamed with a terminal command using regex on MacOS 10.9 Mavericks. The files are named this way: 0045AW489R3T(IPCAM)_0_20131124101245_931.jpg ...
2
votes
2answers
77 views

OS X: how to keep the computer from sleeping during a http connection

An application I use downloads data from a specific server, and I need it to sleep after the download has finished and the socket is closed. However downloads take place at random days, the app that ...
1
vote
1answer
859 views

How can I change my bash prompt to show my working directory?

I can print my current working dir like this myPrompt$ pwd /Users/me/myDir I want my shell to look like this /Users/me/myDir$ pwd /Users/me/myDir Is that possible? How can I do it?
0
votes
1answer
491 views

Trying to cp a path with spaces, fails when scripted but echoing and pasting succeeds? [closed]

I have a script that is trying to copy a directory from a path that includes backslash-escaped spaces and is stored in a string variable to a subdirectory of the working directory. When I run the ...
2
votes
2answers
539 views

How do I make the Xterm window title switch between the current running command and the current path?

I want to set the Xterm window title to switch between two states: When a command is running, show the command name (e.g. "less") When no command is running, show the current path (e.g. "src") I ...
12
votes
6answers
9k views

How can I display the contents of a text file on the command line?

I would like to display the contents of a text file on the command line. The file only contains 5-6 characters. Is there an easy way to do this?
1
vote
1answer
267 views

Non-ASCII characters handled incorrectly on command line

I have a problem with non-ASCII characters in the Terminal on Mac. If I write: echo ÆØÅ Then press Enter, Arrow Up, Arrow Left, so the cursor is between the Ø and the Å, then write X, then the Å is ...
11
votes
2answers
515 views

How to keep dotfiles system-agnostic?

Due to work I have recently started using OS X and have set it up using homebrew in order to get a similar experience as with Linux. However, there are quite a few differences in their settings. Some ...
1
vote
1answer
246 views

Bash script to hide/show files

I prepared a little bash script to toggle the visibility of my hidden OS X files. if (defaults write com.apple.finder AppleShowAllFiles FALSE); then defaults write com.apple.finder ...
2
votes
1answer
138 views

Is it alright to have two PATH variables in .bash_profile

I am trying to setup Metasploit on osx 10.7, but I need to edit my .bash_profile and I noticed something unusual to me. I have been reading about setting the environment variable on ...
0
votes
1answer
207 views

MAC bash commands stop working properly

I was trying to install some stuff for scala development on my MAC, and probably I managed broke the shell/terminal while I was mindlessly running some scripts that I don't know. Now when I start the ...
5
votes
1answer
196 views

Execute multiple bash commands on the output of find

I want to execute some commands using the find -exec option, but I'm not sure what' wrong with this code. Currently, it's only processing the first find result, then getting stuck. I'm using bash in ...
-1
votes
1answer
96 views

Why is ./filename required to run executable script? [duplicate]

After creating a Python script file, test.py, in my home directory, and running chmod +x test.py to make it executable, and placing #!usr/bin/env as the file header, I expected to be able to run the ...
2
votes
1answer
207 views

Find out where $PATH got corrupted

I'm using OSX Mountain Lion 10.8.2 $echo $PATH prints this: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/Users/myusername/.rvm/bin I've commented out everything in ~/.bash_profile ...
1
vote
2answers
753 views

OS X setting environment variables

I have OSX 10.8.2 with ZSH as my shell and iTerm as a terminal (don't know if the last thing is relevant). I have to mention that I'm relatively new to OSX. I'm trying to set up some environment ...
1
vote
3answers
441 views

Print files with file size less than 100 bytes

Basically this script is just supposed to print out the file size and the name of all files in a directory that are under 100 bytes. This script I wrote works perfectly on my Ubuntu, but wont work on ...
3
votes
2answers
212 views

Make copies of a single directory to multiple directories with different names

I'm trying to replicate a single directory (with sub-directories) to a bunch of new directories based on a list. For example I can: mkdir Fred Barney Thelma Louise Foo Bar How would I copy a premade ...
5
votes
4answers
2k views

How to make bash put prompt on a new line after cat command?

What I get: host:~ user$ cat example.txt some texthost:~ stas$ What I want to get: host:~ user$ cat example.txt some text host:~ stas$ Is there a way I can make cat behave like this? I'm using ...
2
votes
1answer
294 views

Display 'PRI' and 'NI' via 'top -stats'

I'm trying to create a script that prints top stat for some specific fields (e.g. pid, command, priority, nice value). I can print most of them by using -stats option, but there is no arg for ni and ...
2
votes
2answers
2k views

How do I parse namespaces from an XML file using XMLLINT and BASH

Below I have an example of an Adobe XML swidtag used to track inventory. I need to parse out relevant information using xmllint in bash and output that to a new text file. For example I would like ...
2
votes
1answer
694 views

What happened to ~ when updating oh-my-zsh?

Not sure what changed the meaning of the home path ~ in my zsh. So when I do cd ~ , I dont cd into my home but it gives me an error that /Users/carlos does not exist. How can I reset ~ to refer to ...
2
votes
2answers
2k views

Fetch values from plist file on Linux

I have bash script which was written for OS X and now ported to Linux. I don't have access to the Linux box. The bash script would read values from plist files using the defaults read and PlistBuddy ...
1
vote
2answers
564 views

ps aux |grep 'asdf' grep: asdf: No such file or directory

For some reason a while back, the behavior of my command line changed, and I don't know why. Using OSX, now Mountain Lion(although this behavior was present before the switch). Using standard ...
7
votes
1answer
1k views

Bash history with timestamps

I would like to keep timestamps on the commands logged in my Bash $HISTFILE, is it possible? I did not manage to set it up using man bash as an information source. My other options are as follows: ...
4
votes
2answers
5k views

Global bash_profile

I realize there are /etc/profile and /etc/bashrc files for setting global environment variables and maybe I'm just misunderstanding their purposes, but... Is their a global bash_profile file? This ...
2
votes
2answers
365 views

Am I using bash after this ordeal?

On Mountain Lion, host Coguaro, I login as user coconutpowder using bash: Coguaro:~ coconutpowder$ echo $0 -bash I need to run a command with elevated privileges so I try to su switch to root but ...
1
vote
2answers
3k views

Why the differences in color between SSH terminal sessions in OSX?

I'm trying to get the colors in an SSH terminal session with a CentOS machine to look the same as it does when I'm SSH'd into my Ubuntu server. If I run echo $TERM in both I get xterm-color as ...
16
votes
4answers
1k views

Finding command execution time in hindsight

I've just executed a long-running process from the bash prompt. In hindsight, I wish I'd run time on it, or noted down the time at which I kicked it off. Is there any way of getting this information ...
3
votes
3answers
3k views

/etc/shadow on Mac

I've been trying to run this Linux passwd-generator file on my Mac. I modified enough the script to make it to work well with directories under OSX: #!/bin/sh # build-passwd.sh - creates a password ...
0
votes
3answers
104 views

Weird behaviour case insensitivity with bash on MacOS

~/testing $ echo Hello > hello.txt ~/testing $ echo Goodbye > goodbye.txt ~/testing $ cat goodbye.txt hello.txt > HELLO.txt ^C ~/testing $ ls -l total 9056 -rw-r--r-- 1 user user 8 ...
1
vote
1answer
667 views

How should I check to see if the remote smb serv is mounted?

I'm pretty new to mount. Basically, I have a remote SMB serv on the local network that I want copy images from a directory on, then repeat every 5 min. I think what I need to do is make a script that ...
3
votes
1answer
159 views

On OS X, how do I log in interactively as root starting from my normal user account?

I have been doing this for a while: sudo su - but it uses 'sh' rather than 'bash', which is what I'd like to do. Which command will log me in as root and get me a bash shell even if that's not the ...