Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9187573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:48:13+00:00 2026-06-17T19:48:13+00:00

I am trying to modify /etc/fstab with sed / awk . Much like in

  • 0

I am trying to modify /etc/fstab with sed/awk. Much like in this question, however, the solutions in that question aren’t quite working for me.

I need to add the nodev (and nosuid) option to nfs or nfs4 mount points.

I have working;

awk '$4!~/nodev/&&$3~"nfs"{$4=$4",nodev"}1' OFS="\t" /etc/fstab > /etc/fstab.tmp && mv /etc/fstab.tmp /etc/fstab

awk '$4!~/nosuid/&&$3~"nfs"{$4=$4",nosuid"}1' OFS="\t" /etc/fstab > /etc/fstab.tmp && mv /etc/fstab.tmp /etc/fstab

However, it obliterates existing white space and replaces with a single tab. My question is: How can I make this change in a less intrusive manner? This answer looked promising, but I don’t understand it well enough to adapt it to my use.

I am open to solutions other than sed or awk, but any other tools need to exist in a default Red Hat/CentOS environment (during %post in Kickstart.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:48:14+00:00Added an answer on June 17, 2026 at 7:48 pm

    Unfortunately, awk does tend to munge whitespace if you change any of the fields. But this is pretty easy with sed. If your sed supports \S to represent non-whitespace, you can do:

    sed 's/\S\S*/&,nodev/4' to append ,nodev to the 4th column. So try:

    sed -e '/nfs/{/nodev/!s/\S\S*/&,nodev/4}' -e '/nfs/{/nosuid/!s/\S\S*/&,nosuid/4}'
    

    If your sed does not allow /S, use [^ ] instead (actuall space and a tab inside brackets.) This does not limit the match of nfs to the 3rd column. Exercise left for the reader.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to modify /etc/hosts/ file and for that I make a separate file
I'm trying to edit a text file that looks like this: TYPE=Ethernet HWADDR=00:.... IPV6INIT=no
I am trying to modify the android lvl library and as part of this
I am trying to modify the script below to click a button that looks
I am trying to modify a batch script that installs a simple script file
I am trying to modify the PDF metadata (title, author, etc.) of an existing
I guess this is a two-part question. I am trying to write my own
I found this keyboard hook code, which I'm trying to slightly modify for my
I'm trying to modify this very simple shell script I wrote to check if
I'm trying to modify an existing application using AWT for dialogs, etc. I don't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.