Results 1 to 3 of 3
is there a way to replace text strings in a file from the command line (no scripts or programming)? I want to replace this line in /etc/inittab Code: id:5:initdefault: with ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 08-06-2007 #1
command for replacing text?
I want to replace this line in /etc/inittab
im making a test and trying to make setup into a single multipart command. what would the command line be?
- 08-06-2007 #2
The sed utility can do pattern matching and replacement. So for your particular example:
sed -e 's/id:5:initdefault/id:3:initdefault/' /etc/inittab
sed uses a technique called regular expressions to match patterns in the file. You can do very powerful things with it: find an online resource on regular expressions for more info.
- 08-06-2007 #3