Ask Your Question
2

In what way can I create an alternative name for gsed as sed on OSX that can be used both in the terminal and in bash scripts?

asked 2022-05-25 11:00:00 +0000

lalupa gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-03-11 00:00:00 +0000

scrum gravatar image

One way to create an alternative name for gsed as sed on OSX that can be used in both the terminal and in bash scripts is to create an alias. You can add the alias to your .bashrc or .bash_profile file for permanent use. Here is an example:

  1. Open your terminal and navigate to your home directory.

  2. Type nano .bashrc or nano .bash_profile to edit the file (use the one that exists).

  3. Add the following line: alias sed='gsed'

  4. Save the file and exit the editor.

  5. Type source .bashrc or source .bash_profile to apply the changes.

Now, every time you type sed in your terminal or bash script, it will use the gsed command instead.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-05-25 11:00:00 +0000

Seen: 10 times

Last updated: Mar 11 '23