New answers tagged

2

I would change two things to make it work the variable need to be put in {} to separate it from the other text (how should bash know that the variable isn't called ilatest otherwise? sleep expects the sleep time in seconds This gives you #!/bin/bash i=0 while true do curl -O link.com/latest.jpg let "i++" mv latest.jpg latest-${i}.jpg sleep ...


2

This is by design. You can see how wc pads “tabs” by removing the -c so it drops the first number in alignment with where the others would be. You can gobble up the white space if you need with another pipe, but you should plan on this if you’re scripting things on macOS and don’t drop a different wc command down. The options are endless echo "test" | wc -...


1

iTerm2 has a built-in mechanism to get notifications but you have to install the Shell Integration. When you start a long-running command, select: Edit > Marks and Annotations > Alerts > Alert on next mark (⌥Option+⌘Command+A) When the command prompt returns you can select between: Show Modal Alert Box Post Notification (example screenshot)


2

You should be able to do this with wildcards. The shell will expand to existing files: convert -append 0_*jpeg 0a.jpg && convert -append 1_*jpeg 1a.jpg && convert -append 2_*jpeg 2a.jpg && convert -append 3_*jpeg 3a.jpg && convert -append 4_*jpeg 4a.jpg && convert -append 5_*jpeg 5a.jpg && convert -append 6_*...


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><...


2

There is a 3rd party app named PDFsam. SAM stands for split and merger. It does exactly what you're looking for and there is a free basic version. This is a newer version than I have but my version has a link near title bar that read Alternate Mix that will do what you described.


3

Looks like your config file got copied by somebody else. Log in as an admin user if you ain't one already and run sudo chown firestarter /Users/firestarter/.ssh /Users/firestarter/.ssh/* sudo chmod 700 /Users/firestarter/.ssh


2

I think you need to put a semi-colon between the two commands instead of &&. I just tried using the semi-colon and it worked fine.


1

From man bash: HISTCONTROL A colon-separated list of values controlling how commands are saved on the history list. If the list of values includes ignorespace, lines which begin with a space character are not saved in the history list. A value of ignoredups causes lines matching the previous history entry to not be saved. A value of ignoreboth is shorthand ...


-1

As the err message indicates, you set a wrong path for bash. bash is located at /bin/bash, not /usr/bin/bash. On some distros, /bin/bash may be a symlink to /usr/bin/bash, but this is NOT what macOS does. Use the following command to setup a correct shell for root. sudo chsh -s /bin/bash root


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,...


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 ...


1

In Finder: Set to make visible unvisible files, select your home folder, Enter TimeMachine, select a date before the reinstall, select .bash_profile and restore it.


5

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 ...


0

Running fd0's solution: find /Volumes -type d -path '*outerfolder/innerfolder' You get the annoying "Permission denied" messages. You could send all error messages to /dev/null, but that's too drastic to me. find: /Volumes/4T Virtual Machines/.DocumentRevisions-V100: Permission denied find: /Volumes/4T Virtual Machines/.TemporaryItems: Permission denied ...


-1

I haven't used Windows in to many years; however, I understand there is a new Windows 10 feature called Windows Subsystem for Linux. Have a look at Everything You Can Do With Windows 10’s New Bash Shell and How to Install and Use the Linux Bash Shell on Windows 10. Maybe using this feature will enable one to create and zip a bash executable and retain its ...


1

Question asker here ... I had the fortunate luck of working through this in a screen share with a graduate from the school and the solution we found regarding my issue is that I had this in my .bash_profile file: source ~/.bash_profile export PATH=$PATH:~/.npm-global/bin So, the immediate issue was the source ~/.bash_profile, this was causing the piping ...


1

There was a mistake on the pathfile name (after Anki2/me/...) : the user profile was actually "me_201908". Also, this time around I edited the file in vim and used $HOME in the variable's pathfile.


3

I like zigg's solution. In order to keep it short I did this: In /Users/{username}/.bash_profile add a line alias taskready='afplay /System/Library/Sounds/Hero.aiff' Quit the terminal and open the terminal. Now you can use the shorthand command taskready. You can choose from: Basso.aiff Frog.aiff Hero.aiff Pop.aiff Submarine.aiff Blow.aiff ...


3

Assuming innerfolder needs to be directly within outerfolder: find /Volumes -type d -name "outerfolder" -exec test -d {}/"innerfolder" \; \ -exec echo {}/"innerfolder" \; (formatted for readabiliy, you can also put everything on one line and remove the trailing \ from the first line)


3

I'm not quite sure of what you are looking for but the following will list all directories named "Virtual Box" starting with the deepest nested to the least. find /Volumes -type d ! -name Volumes -name "Virtual Box" 2>/dev/null EDIT: OK, understanding your requirement a bit better we can use the path predicate to match outerfolder/innerfolder find /...


3

The shell uses a space character as a separator between words, so paths containing spaces always must be put in "" when used (which implies that it is recommended/best practice to ensure that all paths and file names in shell scripts and init files are properly quoted): ANKI_MEDIA="/Users/<username>/Library/Application\ Support/Anki2/me/collection....


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 ...


2

The answers here do not always contain best practices, so if you just want the directory echoed on the screen (even when it contains spaces): #!/bin/bash echo "My Script is being run from here: $(dirname "$0")" If you want it into a variable and want . expanded to the full path, you need GNU Readlink first so: Install homebrew Install GNU CoreUtils: brew ...


3

See the answers on Get the source directory of a Bash script from within the script itself. The accepted one recommends #!/bin/bash DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" but reading all the answers gives a lot of alternatives (and insights into how shells work).


0

You can activate a virtual environment for conda by running conda activate base Replace base with whatever (defined) conda environment you want to use. pse@Mithos:~$ export PS1="\[\e[30;47m\]\W\[\e[30;47m\]$\[\e[0m\]" ~$cd .tmp /Users/pse/.tmp .tmp$conda activate base ((base) .tmp$conda deactivate .tmp$


Top 50 recent answers are included