Hot answers tagged

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.


2

You need to enclose the non-printable characters properly in \[...\] block. This ensures that correct number of characters are counted while generating the prompt. I had the same problem and here's the PS1 that gave no issues so far : \[\e[30;47m\]$(parse_git_branch)\W\[\e[30;47m\]$\[\e[0m\] That is my understanding of what I read on SO: You should ...


2

It's a conda's environment indicator that none of the "new" environments is active, instead the default one is active. "new" here refers to those created by: conda create --name NameOfEnv python=3.6 or similar. For getting rid of it, add the line conda deactivate at the end of ~/.bash_profile. Verify by conda info --envs.


2

The ifconfig binary is located in /sbin/ which doesn't seem to be in your $PATH. You can add it by appending the line /sbin to /etc/paths.


2

The stream editor sed is likely the fastest and sharpest tool built for exactly this task. Use the insert command (the newline after \ is part of the syntax): sed 'i\ X' file > newfile $ time sed 'i\ X' line250000 >/dev/null real 0m0.118s user 0m0.102s sys 0m0.012s The delay or overhead for this operation is ...


2

You should be able to just run t=${TMPDIR:-/tmp}/target mkdir "$t" find . -type f -name '*.STY' -exec cp {} "$t"/ \; mv "$t"/* ./styleFiles_chekad/ rmdir "$t" The idea behind using a temporary directory is to prevent find from also copying the files it already moved into ./styleFiles_chekad/.


1

The properties of themes and profiles are stored in ~/Library/Preferences/com.apple.Terminal.plist in the key Windows Settings/[Name of the Profile]: Obviously only diffs to a hidden default profile (it's not the Basic profile!) are stored. In the example above I made a copy Basic 1 of the Basic theme and arbitrarly disabled and enabled settings in the ...


1

The screenshot shows the content of /usr/bin, not of /bin :-)


1

If you do not want to change your shell from bash to zsh, then add this to your .bashrc file: export BASH_SILENCE_DEPRECATION_WARNING=1 To edit this you can use this command: nano ~/.bashrc While you are editing your .bashrc file, look for aliases or functions which redefined ls use Ghostscript. Try which -a ls in Terminal.app to show you what ls is ...


1

Gathering what's above in the comments, here's what works: Use Script Editor to write a script containing do shell script "complete_path_to_start_script" on quit do shell script "complete_path_to_quit_script" continue quit end quit Use Script Editor to export the script as a standalone app which remains open after the start script has terminated. ...


1

Make sure that the shell script within Borg.app is executable (chmod +x ...) all the files within Borg.app are accessible by the current user any command called from the script is called with the full path specified (especially for things stored in /usr/local/bin and similar non-default places)


1

It's a bug related to the old version of bash included in macOS. To overcome you can Switch to zsh (see What are the practical differences between Bash and Zsh?) Install a more recent version of bash via Homebrew and use this as your standard shell (see How to use bash as default shell)


1

print is not a standard bash command. I think so because man print returns no manual entry. puts is a Standard C Library function and should be used inside a file and used as: #include <stdio.h> puts(const char *s); The function puts() writes the string s, and a terminating newline character, to the stream stdout. An example: /* puts ...


1

Terminal has a setting to use the default shell or run any program. I would make the election you wish: If that's not it, you'll have to hunt down each of your initialization files. Before doing that, make a brand new user account to be sure you have a working zsh for that user and terminal overall. It's probably the obvious item above, though.


1

This bash snippet will prepend each line of a file with a hash (#) and save it to a new file: IFS=$'\r\n'; printf '#%s\n' $(</path/to/file.txt) > /path/to/newfile.txt Explanation IFS=$'\r\n': This sets the field separator so that only the characters \r (carriage return) and \n (newline) are used to delimit a string. The default setting can be ...


1

If target is an already existing directory, then the command ln -s source target will create a link target/source in that directory, pointing to the original source. That's what's going on here: the directory .emacs.d/snippets/ exists at the start, and you're running the command ln ~/.dotfiles/.emacs.d/snippets ~/.emacs.d/snippets which creates a link in ...


1

It looks like the proper two programs to give full access to are: cron terminal.app See rsync in cron on Catalina no longer working


1

Add this line to your .bashrc or .bash_profile if you don't want to see the "garbage" anymore. PROMPT_COMMAND="{ ${PROMPT_COMMAND}; } 2>/dev/null" caveat: stderr output from ${PROMPT_COMMAND} will be muted.


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