Hot answers tagged

148

First, some important things: Bash isn't going away. If you're already using bash, nothing will change for you. All that changes is that zsh will be the default login shell for new accounts, and even then, you can select bash instead. Scripts are not affected. What changes is the shell for interactive use, i.e. the shell in terminals (and also a few other ...


42

This is SilverInstaller, adware to download more adware and ‘potentially unwanted programs’. This was likely distributed through fake Flash popups, which someone on the system clicked on, downloaded, opened, installed and provided administrator credentials to. Installed software in this package likely includes MacKeeper, VSearch, A Pirrit injector,...


34

It looks like there exists a line :wq in one of your shell’s profile files, such as ~/.bash_profile, which was probably added as a failed attempt at quitting Vim when editing such a file. To edit the bash profile with TextEdit, run open -e ~/.bash_profile in Terminal. Edit the file to remove the :wq line only. Save it, quit TextEdit and restart Terminal to ...


17

Change your shell now and test - no need to wait. chsh -s /bin/zsh All the scripts that depend on bash syntax will still find and call bash. the same bash from Mojave is shipping on Catalina and migrated users keep their old shell. Many blogs have great write-ups on moving preference files - here is one such - https://scriptingosx.com/2019/06/moving-to-...


13

You can't easily (and shouldn't) change/upgrade /bin/bash. You can install a more recent version of bash through Homebrew though, and use the information from How to use bash as default shell to change your login shell. This will not break any existing bash scripts as these refer to #!/bin/bash in the first line.


11

Simply set the EDITOR variable to vim in your bash startup file. EDITOR=vim From the bash manual edit-and-execute-command (C-xC-e) Invoke an editor on the current command line, and execute the result as shell commands. Bash attempts to invoke $FCEDIT, $EDITOR, and emacs as the editor, in that order.


10

!! is a history command of bash, it gets replaced by the last command you‘ve executed. You can try ls followed by echo !! $(...) performs Command Substitution, the output of a command replaces the command name (the part within the ()). Again, echo $(!!) helps to illustrate this So rm $(!!) removes all files whose names are printed after re-running the last ...


10

Prepend each line of a file with a capital A and write a new file- awk '{print "A"$0}' < FILE > NEWFILE


9

To prepend X to the start of every line of file, writing to newfile, in Terminal: sed 's/^/X/' file > newfile Here I'm using sed, the Unix stream editor, to use a very simple regular expression to substitute the beginning of every line (the ^ symbol) with an X.


8

The . command is an alias for source so the two commands are really ./venv/bin/activate and source venv/bin/activate Also note that for the system to actually process a file it needs the absolute path ie one beginning with / Both files names here are relative ones ie ones that can only be understood with the knowledge of the current directory which ...


8

There can be multiple reasons as to why this happens - I'll try to outline how it works below. However, I can say that the other answer you have received here is not correct. HISTFILESIZE and HISTSIZE will not cause your history to "sometimes" being entirely wiped out or almost wiped out. Only by setting them to 0 you would get nothing in the files - but ...


7

From man bash: . filename [arguments] source filename [arguments] Read and execute commands from filename in the current shell environment and return the exit status of the last command executed from filename. If filename does not contain a slash, filenames in PATH are used to find the directory containing filename. The file searched for in ...


6

On Mojave, spindump doesn't seem to list the fan speed. Noticed that powermetrics does, though. Try running sudo powermetrics | grep Fan if you are on Mojave.


6

My shell scripts are really not that complicated Do your shell scripts have shebang lines (begin with #! /bin/bash or similar)? If not, you might have unintentionally been using a bash feature, where it runs scripts without a shebang using bash. Other shells, like dash or zsh, leave it up to the OS, which would usually use /bin/sh instead. /bin/sh on macOS ...


6

As you are already using awk and are looking for a simple solution: awk -F/ '{n=split($3, a, "."); printf("%s.%s", a[n-1], a[n])}' <<< 'http://www.example.com/index.php' ^ ^ ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^ | | | | | | | last two ...


6

Turns out the terminal app has its own settings for which shell to use. I had to go to terminal preferences and change the option for Shells open with to Default login shell:


6

You do not even need to enter Time Machine, although your Time Machine drive must be connected and mounted. In Terminal, which by default opens to your $HOME directory, you can use the following command, literally, to copy the .bash_profile file to your $HOME directory: cp -av /Volumes/*/Backups.backupdb/*/Latest/*/Users/$USER/.bash_profile . Note that ...


5

It appears you want to send some number (586?) lines from FTIG_dldStruct.txt to the ./STP command? If so, assuming ./STP reads from standard input as is typical, that may look like: head -n 586 FTIG_dldStruct.txt | ./STP As pointed out in the comments to pass the entire contents of the file that would be: ./STP < FTIG_dldStruct.txt Various pipelines ...


5

I prefer to use the system configuration utility tool to test for reachability instead of using ping / host / nslookup or another proxy for determining if a network entity is or is not reachable. scutil -r google.com Reachable The benefits of this are that if you have VPN connections, dial up, modem, or a routing conflict, this will actually test that you ...


5

The /etc/profile file, which Bash executes for login shells, includes the following content: # System-wide .profile for sh(1) if [ -x /usr/libexec/path_helper ]; then eval `/usr/libexec/path_helper -s` fi if [ "${BASH-no}" != "no" ]; then [ -r /etc/bashrc ] && . /etc/bashrc fi It's the path_helper program that sets up the PATH environment ...


5

If you want to list all files/folders in a directory, you should type ls not Is. It is L, not i. To learn python, you won't need to reach ~/.bash_profile unless you need to change versions. Just use which python or python --version and use the syntax for the version that appears. Or use online compilers for quick testing. Suppose you have your file learn....


5

That script does everything I would expect malware to do and has been around for a while so the domains it connects could be blocked or shut down now. Downloads some files, runs those files and cleans up after itself. It could be ad(vertising)ware instead of malware, but it’s clearly fingerprinting your mac, reporting a unique identifier for your Mac and ...


5

Storing parts of commands in variables and/or using eval is a good way to get weird parsing problems. I'd use a shell function instead: addDockApp() { defaults write com.apple.dock persistent-apps -array-add \ "<dict><key>tile-data</key><dict><key>file-data</key<dict><key>_CFURLString</key><...


5

You can use pkgUtil for it. $ pkgutil --pkgs # list all installed packages $ pkgutil --files the-package-name.pkg # list installed files After visually inspecting the list of files you can do something like the following: I leave this up to you as modifying files with root user maybe a bit risky $ pkgutil --pkg-info the-package-name.pkg # check the ...


4

There is a tool called homebrew-autoupdate which will do this for you. It can automatically run brew update in the background every 24 hours (configurable) to ensure that you always have fresh homebrew data when you go to install/upgrade packages. To install it run brew tap domt4/autoupdate and brew autoupdate --start 43200 to configure it to autoupdate ...


4

I was able to get it to work by making sure the /etc/resolver.conf existed in the chroot and then symlinking /var/run/mDNSResponder into the chroot. $ sudo chroot -u user "/Users/user/Source/macos-mkjail/test_jail" /bin/bash bash-4.4$ ping www.google.com PING www.google.com (216.58.194.164): 56 data bytes 64 bytes from 216.58.194.164: icmp_seq=0 ttl=53 time=...


4

In spite this post is old, I decided to leave my solution here to help community with one more approach. note: I wrote a medium with more description. In my case, I din't have that extra partition available so, in recovery mode: Run the terminal run diskutil list Find the identifier of "VM" volume. In the case of the previous image is "disk1s5". ...


4

OK - no worries. You did in fact mess things up, but here's an easy way to fix things. Open TextEdit (or whatever editor you like graphically on the Mac) Open a file and go to your home folder (click or press Command Shift G and type ~ and return) Show hidden files (if needed) - Command + Shift + . Open .bash_profile Delete everything or comment out ...


4

I'd recommend a somewhat different approach from @bmike: rather than trying to remove the bad parts from the current file, start over and add back just the good parts. It looks like there's a lot more bad than good in the current file, so this should be simpler. What's really really really bad in the current file is the section that starts like this: cat &...


4

Your problem is that you're using invalid options for the ping command. It seems likely that you have copied a command line intended for use on Linux, and tried to use it unmodified on macOS. The specific problem here is that Linux uses "-w" to specify timeouts, whereas macOS uses "-t". This means that your command line should instead be this: ping -q -t1 -...


Only top voted, non community-wiki answers of a minimum length are eligible