LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.

Notices


Reply
  Search this Thread
Old 09-20-2006, 01:07 PM   #1
djr
LQ Newbie
 
Registered: Oct 2004
Posts: 2

Rep: Reputation: 0
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
 
Old 09-20-2006, 01:12 PM   #2
w3bd3vil
Senior Member
 
Registered: Jun 2006
Location: Hyderabad, India
Distribution: Fedora
Posts: 1,191

Rep: Reputation: 49
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.
 
Old 09-20-2006, 11:48 PM   #3
mdhmi
Member
 
Registered: Dec 2005
Location: Detroit, Michigan
Distribution: Ubuntu
Posts: 86

Rep: Reputation: 15
sed would be the easiest solution.
 
Old 09-21-2006, 12:11 AM   #4
w3bd3vil
Senior Member
 
Registered: Jun 2006
Location: Hyderabad, India
Distribution: Fedora
Posts: 1,191

Rep: Reputation: 49
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
 
Old 09-21-2006, 12:30 AM   #5
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Code:
sed 10d file
 
Old 09-21-2006, 06:22 AM   #6
w3bd3vil
Senior Member
 
Registered: Jun 2006
Location: Hyderabad, India
Distribution: Fedora
Posts: 1,191

Rep: Reputation: 49
not delete the line, insert a hash.
 
Old 09-21-2006, 06:55 AM   #7
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Code:
sed '10 s/^/#/'
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
modifying a file in shell (via sed ?) Shautieh Programming 7 09-19-2006 05:14 AM
Modifying the Boot Options and the mbr file sfzab SUSE / openSUSE 5 12-23-2005 03:46 AM
Modifying LiveUSB file system LlamaNerds Linux - Software 5 11-17-2005 12:42 PM
Modifying a .gif file kaplan71 Linux - General 2 06-29-2004 08:13 PM
creating or modifying file system tanmaya Linux - General 1 12-24-2003 01:03 PM

LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris

All times are GMT -5. The time now is 08:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration