Find the answer to your Linux question:
Results 1 to 2 of 2
I otherwise wouldn't ask this, but after a long time searching the internet for what I thought would be a quick and simple answer, I haven't found it So then, ...
  1. #1
    Just Joined!
    Join Date
    Jul 2007
    Posts
    1

    Saving Changes After Sed Command?

    I otherwise wouldn't ask this, but after a long time searching the internet for what I thought would be a quick and simple answer, I haven't found it

    So then, I'm pretty new to Linux and BASH and I'm trying to make a shell script to remove a column from a tab-delimited .dat file, put it in a new folder, remove all instances of a certain string (%) and save the changes.

    #!/bin/bash
    cat ./wReadings.dat | cut -f 3 - > humidity.dat
    cat ./humidity.dat | sed 's/%//'
    The replacement change doesn't save though, and I can't find the command to make it do so. So how can I?

    Thanks a lot.

  2. #2
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    Location
    Texas
    Posts
    1,692
    You could just redirect the results to a new file.

    Or read the manpages for sed(1):
    -i extension
    Edit files in-place, saving backups with the specified extension.
    If a zero-length extension is given, no backup will be saved. It
    is not recommended to give a zero-length extension when in-place
    editing files, as you risk corruption or partial content in situ-
    ations where disk space is exhausted, etc.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...