LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Solaris / OpenSolaris (https://www.linuxquestions.org/questions/solaris-opensolaris-20/)
-   -   modifying a file without and editor (https://www.linuxquestions.org/questions/solaris-opensolaris-20/modifying-a-file-without-and-editor-485366/)

djr 09-20-2006 01:07 PM

modifying a file without and editor
 
Hi.

I am wanting to find a way to modify a file, for instance (vfstab)'example only'

lets say I have an entry(line) in there that I need to '#' out, but are un able to vi or us any other editor on the file

I seen people change the line of a file by using a string command. not sure if it was a cat/sed/echo....

For the life of me I can not remember how they did it.


thanks

w3bd3vil 09-20-2006 01:12 PM

hashing out a line cannot be done through cat or echo. using echo you could append a line. you could do it by sed but that would be complex.
vi is always there and if you can use cat you can also use vi.

mdhmi 09-20-2006 11:48 PM

sed would be the easiest solution.

w3bd3vil 09-21-2006 12:11 AM

mdhmi, could you give me a command using sed to hash out 10th line out of a 17line file. :)
eg
Quote:

1
2
3
4
5
...
#10
11
..
17

jlliagre 09-21-2006 12:30 AM

Code:

sed 10d file

w3bd3vil 09-21-2006 06:22 AM

not delete the line, insert a hash.

jlliagre 09-21-2006 06:55 AM

Code:

sed '10 s/^/#/'


All times are GMT -5. The time now is 06:41 AM.