Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Specific Line in Configuration Files #1

Open
PeterTeng opened this issue Sep 26, 2018 · 2 comments
Open

Remove Specific Line in Configuration Files #1

PeterTeng opened this issue Sep 26, 2018 · 2 comments

Comments

@PeterTeng
Copy link

It is possible to use sed command to remove specific line which match desired pattern

https://www.gnu.org/software/sed/manual/sed.html

sed Command Usage

$ cat a.txt
ip:111.111.111.111 text text text
ip:222.222.222.222 text text text
ip:333.333.333.333 text text text
ip:444.444.444.444 text text text

# Remove the line in file and print file with STDOUT
$ sed '/222.222.222.222/d' a.txt
ip:111.111.111.111 text text text
ip:333.333.333.333 text text text
ip:444.444.444.444 text text text

# Remove the line in file and modify the file
# In macOS --> sed -i '' '/222.222.222.222/d' a.txt 
$ sed -i '/222.222.222.222/d' a.txt 
$ cat a.txt
ip:111.111.111.111 text text text
ip:333.333.333.333 text text text
ip:444.444.444.444 text text text
@100010
Copy link
Owner

100010 commented Sep 26, 2018

@PeterTeng thanks for your issue.

POSIX compliant sed as typified by BSD sed etc. is used as standard in OS X etc, but sed used in general Linux is often GNU sed. Therefore, if Linux users use OS X's sed, they will be confused with so-called "dialect" like differences such as options.

So I used pure shell script, what do you think?

@PeterTeng
Copy link
Author

@100010 Thanks for the quick response!

I think this proxy server creation are mostly needed on Linux, so that the confusing "dialect" with sed command between macOS and Linux is not a big problem.

Linux Kernel/Distribution

Maybe by checking Linux distribution, we can "reject" user who want to create proxy server on macOS with this gem. Cause it is not a supporting OS.

# Kernel version
$ uname -a
$ cat /proc/version
# Distribution (/etc/os-release, /etc/system-release ...)
$ cat /etc/*-release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants