Questions tagged [bash]

The default Unix shell used by Terminal in macOS

Filter by
Sorted by
Tagged with
1
vote
3answers
83 views

How to open PDF as BASH variable?

I'm trying to open a PDF using Preview where the input file is a shell var: $ pdf=$(wget -qO- 'http://website.com/file.pdf') && open "$pdf" $ pdf=$(wget -qO- 'http://website.com/file.pdf') &...
0
votes
2answers
32 views

Find all the PDFs with at least three characters in their name

I'd like to find the PDF files whose name (excluding the extension) is greater than three. $ find ~ -iregex '.*/[^/]{3,}.pdf' when test with $ find ~ -regextype posix-extended -iregex '.*/[^/]{3,}....
3
votes
1answer
410 views

Is it possible to remove the $ from an environment variable?

I'm on Mac and have just created an environment variable inside the .bash_profile directory, it works fine when I run: $variable_name I just want the know why the dollar sign is there and if it is ...
1
vote
1answer
225 views

How to save root aliases permanently?

i tried saving aliases (see below) for the root user in .bash_profile to /var/root/.bash_profile and restarting Terminal, but it didn't work. where does the .bash_profile file need to be to maintain ...
1
vote
2answers
60 views

Run command from terminal by shortcut

I am trying to run copyq menu which is opening the menu context. This supposed to worked, but I got copyq command not found and struck at this step. I had tried putting the /Users/myname/.bash_profile ...
2
votes
1answer
135 views

Simplest and Sure manner adding multiple Groups and Users, CentOS 7, macOS

I have this instructions on CentOS 7 Linux version. $ sudo groupadd oinstall $ sudo groupadd dba $ sudo groupadd oper $ sudo useradd -G dba,oper -g oinstall oracle $ sudo passwd oracle And Already ...
1
vote
1answer
54 views

Help with waiting while a process is running

I'm looking for a bash script that checks if the Installer process is running and waits/pause if it then proceeds once the process is no longer running. Here is what I have so far: #!/bin/bash ...
1
vote
1answer
47 views

Help with loop/counter script

I'm trying to create a simple loop/counter script to display information about installed printers. Main the Name, PPD, PPD Version, and URI. I have two problems... 1 - the name is not coming up; 2 -...
1
vote
1answer
55 views

Help with a bash script to proceed if bundle id is found

Looking for some help writing a bash script that checks if a particular bundle id is installed and proceeds to install the package if not found. Found that we can use "mdfind ...
2
votes
1answer
44 views

Should PS1 be defined before exported in .bash_profile?

In .bash_profile, should PS1 be defined before exporting? As an example, the first line in my .bash_profile is currently: export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\...
4
votes
3answers
6k views

How can I set the iTerm2 window title to be the same no matter which pane is selected?

I'm aware that the iTerm2 window title can be set with echo -ne "\033]0;"Title goes here"\007" but that appears to only set the title for a single pane. When I switch panes, the window title is ...
2
votes
2answers
395 views

Cannot change directory in Terminal if target has spaces in it

I plugged my external HD, then in a Terminal, I type ls /Volumes/TOSHIBA\ EXT This lists files and folders as expected, but then entering: cd /Volumes/TOSHIBA\ EXT throws the following message ...
2
votes
1answer
224 views

Automator fail with ffmpeg bash line

I want to batch convert .m4a music from iTunes to a flash drive as .mp3 This bash script... (source https://ubuntuforums.org/showthread.php?t=1614765) for f in *.m4a; do ffmpeg -i "$f" -acodec ...
3
votes
1answer
69 views

Adding random suffixes to filenames

I would like to change the filename of a lot of files by adding a random suffix to the existing filenames. I have tried to change this code (changes the filename instead of adding a suffix) but ...
1
vote
0answers
58 views

How to close a mission control space using hotkey?

Using "Better Touch tool", I have a hotkey set to "Add New Space To Mission Control". I would like to create the inverse of this and set a hotkey to close the current space. Specifically, I would like ...
2
votes
1answer
221 views

Close Terminal using 'exit' when only one window is present, close window otherwise

When I use the Terminal application I want to close it using the command exit if only one Terminal window is open. If more than one window is open, I want to close just the window that executed the ...
1
vote
1answer
63 views

Simulate shell environment available to GUI Apps?

I'm testing some scripts which are destined for use inside various GUI Apps, either as direct shell calls or as part of an AppleScript do shell script call. I know from experience that the shell ...
6
votes
2answers
345 views

Understanding directory permissions in UNIX

I've been trying to learn Unix and Terminal a bit better, and I've come across some behavior I don't understand. Hoping someone can explain to me what I'm missing. Lately I've been experimenting with ...
3
votes
1answer
759 views

When I type 'echo $path' in Terminal, I see only a blank line - why?

I know I have a $path variable. If I type 'env' or 'set' at the Terminal command line, I can see what's in the $path variable - along with lots of other extraneous stuff. But if I just type 'echo $...
3
votes
1answer
26 views

Upgrade or install Utility `stat`

I tried to install GNU utility stat $ brew install stat Error: No formulae found in taps. However,it succeeded to install GNU Bash How to achieve such a task?
1
vote
2answers
529 views

Reset terminal environment to start up state, not losing print of history

This might seem like a duplicate at first sight, but bear with me for a minute. TLDR; A quick command line way to restore the whole shell environment to the same as upon terminal startup, while not ...
2
votes
0answers
22 views

Processes display not allowing page down

The display hangs on one page after I invoke process through command top, Press 'space', 'arrow' take no effects. I got recommend to use htop, but find it complicated to manipulate. How to page top ...
1
vote
0answers
25 views

Booting from another partition via bash

I want to create a little bash script that restart my mac and boots from another partition. Of course I could do that with changing the startup partition, but that would cause that it would always ...
3
votes
1answer
52 views

Identify a partition from script

I have a bash script that needs to find out itself from which partition / disk it is running from. Unfortunately, I don't know how to do that or if there is a piece of software that can help me with ...
5
votes
3answers
480 views

Prepend folder names to file name and flatten file structure

I have a bunch of folders with various names, for example 2013-02 Snow and birds PICT0001.jpg PICT0002.jpg 2013-06 Bicycle trip edited_panorama.jpg From phone DCIM0001.jpg ...
0
votes
1answer
266 views

Mac: installing homebrew messed up .profile in terminal

I was following this tutorial https://gorails.com/setup/osx/10.13-high-sierra to download Rails. Upon completed this tutorial, I noticed that my terminal's color code, alias, display format when ...
2
votes
0answers
65 views

path difference on script vs in shell

Why is the output of $PATH different when in a script vs when running $PATH from the terminal? Even for a minimal script like this: #!/bin/bash echo $PATH it will not match what I get when typing in ...
4
votes
1answer
214 views

How to make an alias permanent?

I create an alias behavior alias chrome="open -a 'Google Chrome'" chrome foo.html Nevertheless, It refuses to work when I restart the terminal. $ chrome foo.html -bash: chrome: command not found ...
5
votes
2answers
13k views

Open HTML file with Google Chrome using command-line [duplicate]

In default installation of macOS, Python and Bash are installed in /usr/bin and /bin directories respectively. $ which python /usr/bin/python $ which bash /bin/bash So it's appropriate files can be ...
0
votes
1answer
31 views

Update programs of BSD to latest

The programs of BSD in MacOS are not upgrated to the latest Take examples: man ls BSD May 19, 2002 BSD V.S. FreeBSD 11.1 December 1, 2015 ...
1
vote
2answers
45 views

Create symbolic links for multiple books collected from command `find`

I'd like to create symbolic links for multiple books searched from running find command. Firstly, I collect all the JS books find ~ -type f -iregex '.*javascript.*\.pdf' > js_books.md 2>/dev/...
12
votes
3answers
27k views

Missing ftp command line tool on macOS

Use ftp to obtain source code. I am following a linux command line book to learning compiling. [me@linuxbox src]$ ftp ftp.gnu.org Connected to ftp.gnu.org. 220 GNU FTP server ready. I tried and ...
2
votes
2answers
248 views

Copy files searched with find command using xargs command

I'd like to copy the files searched using find command into the current directory. I am executing the following command-line: # find linux books $ find ~ -type f -iregex '.*linux.*\.pdf' -print0 |...
2
votes
2answers
2k views

How to get a list of the installed app on my Mac? [duplicate]

How I can parse the list of all Mac applications? I am executing: ls /Library/Preferences/ > apps.txt But still there are some apps that are missing from the list. I think it parse only user apps ...
0
votes
2answers
56 views

Use specified quantifier in grep to retrieve satisfied vocabulary

I try to grab words from a file: $ grep -o '\*\*[^*]*\*\*' Principles_20_LifePrinciples.md | grep -v -e "Origin" -e "Etymology" **circumstance** **case** **condition** **Anxiety** **anxiety** **the ...
4
votes
1answer
128 views

Retrieve formatted manual page from command line [duplicate]

I try to export the manual page of grep to grep.txt $ man grep > ~/desktop/grep.txt It displayed in garbled code: GREP(1) BSD General Commands Manual ...
3
votes
2answers
96 views

Enable grep to exactly match the regular expression

Enable command 'grep' the return the regular expression matched exactly. Command grep will print a line when the line contains a string that matches an expression, which not handy to search specified ...
3
votes
1answer
66 views

Search Bear notes using `grep` command

With grep, I can search through the content of all the files in a directory, for an instance: grep 'program' *.md searches for the pattern program within the content of all .md files in the current ...
1
vote
1answer
101 views

Newly created alias should be activated constantly

I add an alias to `~/.bashrc and activate it. # add some helpful aliases alias l.='ls -d .* --color=auto' Activate it source .bashrc It work well on current bash. $ l. ls: --...
2
votes
0answers
75 views

Errors with 'echo [A-Z]*'

Errors with 'echo [A-Z]*' I am working on the root directory and intending to print those starting with upper letter. $ echo [A-Z]* Applications Library Network System Users Volumes bin cores dev ...
2
votes
0answers
172 views

Can I modify iTerm window titles for some but not all running commands?

I was looking for a solution to auto set custom title in the terminal based on what command is being run on the current terminal. So, rather than java showing in many tabs - I'd love to have it pick ...
1
vote
2answers
1k views

Mac mail mail from cron

From sandeep@Sandeeps-MacBook-Air.local Fri Mar 23 20:04:23 2018 X-Original-To: sandeep Delivered-To: sandeep@Sandeeps-MacBook-Air.local From: sandeep@Sandeeps-MacBook-Air.local (Cron Daemon) To: ...
1
vote
1answer
560 views

Deleting a line from Bash profile

So using terminal I typed in: nano .bash_profile I then have access to the following bash_profile : GNU nano 2.0.6 File: .bash_profile ...
3
votes
0answers
2k views

How can I mount Google Drive File Stream before launchd user agents start?

I have a simple backup bash script that dumps the output of pg_dump for a PostgreSQL database into a Google Drive File Stream directory. This bash script is referenced by a launchd user agent. The ...
2
votes
1answer
63 views

Looking for a way to run a command depending on OS version

I'm trying to create a bash script that runs a command based on OS version that way I can deploy it to machines running 10.12 and 10.13 the only problem is depending on the version the command needs ...
0
votes
1answer
1k views

How to do Terminal.app Star Wars ASCII? [duplicate]

I tried telnet towel.blinkenlights.nl and it said telnet: command not found. Is it deprecated? It is a bit trivial, but I thought it was worth asking about at least.
0
votes
1answer
234 views

Brew bash autocompletion

I just installed bash 4.4.19 through brew on my mac and configured Terminal.app to use it as the default shell. All of that works. Now when I type ln -s $HOME/+TAB it gets autocompleted to ln -s \$...
0
votes
1answer
53 views

How can I get a logged user's username without the domain?

I'm trying to write a script to automate a task that involves the logged user's username. The problem is the username is coming up as domain/username and I just need the username. LOGGEDUSER=$(stat -...
0
votes
1answer
94 views

bash prompt acting weird when I click UP key and then down KEY

So my bash prompt looks like this [parth:~]$ and if I go cd to Desktop, it looks like this [parth:Desktop]$. I only want to see the current directory, next to my username so if I go to a folder, in ...
1
vote
0answers
65 views

Browse files from iPhone with Terminal [duplicate]

I want to know to browse files from iPhone with Bash Terminal or other tools on Mac. Does anybody of you know how to do this ? Thank you for your answers