LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-23-2015, 12:36 PM   #1
publicLearner
LQ Newbie
 
Registered: Mar 2015
Location: Washington, DC
Distribution: Mac 10.10 Yosemite
Posts: 24

Rep: Reputation: Disabled
sed creating an extra file with e at the file name


Hi Members,

I've file named A200205__mlst__Staphylococcus_aureus__results.txt
It has column 1 as:

Quote:
Sample
A200205_GGTGAGTT_L007
I'm running below command:
Quote:
sed -ie s/out_paired_//g A200205__mlst__Staphylococcus_aureus__results.txt
It replaces out_paired_ in line 2 of column 1 to null.
I'm having the desired output, however, surprisingly a new file is created with name A200205__mlst__Staphylococcus_aureus__results.txte; i.e an extra e

I am unable to figure it out the cause of this hack!
 
Old 04-23-2015, 12:45 PM   #2
millgates
Member
 
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 840

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
the sed manpage says:

Code:
       -i[SUFFIX], --in-place[=SUFFIX]

              edit files in place (makes backup if SUFFIX supplied)
that is, the -i switch replaces the contents of the file passed as argument instead of writing to standard output. However, if you supply a suffix to -i, sed creates a backup of the original file with the suffix appended to the filename.
So, in this case, you used an -ie switch and the "e" is interpreted as the suffix for the -i switch.
If you want to avoid this, separate the switches:
Code:
sed -i -e ...
 
1 members found this post helpful.
Old 04-23-2015, 01:31 PM   #3
publicLearner
LQ Newbie
 
Registered: Mar 2015
Location: Washington, DC
Distribution: Mac 10.10 Yosemite
Posts: 24

Original Poster
Rep: Reputation: Disabled
Hi millgates,
Thanks.

That worked like charm.
Got to be reading MAN pages more closely.


Quote:
Originally Posted by millgates View Post
the sed manpage says:

Code:
       -i[SUFFIX], --in-place[=SUFFIX]

              edit files in place (makes backup if SUFFIX supplied)
that is, the -i switch replaces the contents of the file passed as argument instead of writing to standard output. However, if you supply a suffix to -i, sed creates a backup of the original file with the suffix appended to the filename.
So, in this case, you used an -ie switch and the "e" is interpreted as the suffix for the -i switch.
If you want to avoid this, separate the switches:
Code:
sed -i -e ...
 
  


Reply

Tags
sed bash


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
[SOLVED] AWK / SED - Parsing a CSV file with comma delimiter, and some extra needs. PenguinJr Programming 8 05-24-2011 07:28 PM
[SOLVED] Sed – how do I save output to file with filename from content of another file? misarab Programming 4 02-28-2011 03:12 PM
sed delete lines from file one if regexp are listed in file two fucinheira Programming 6 09-17-2009 09:28 AM
using sed to insert line into file and overwrite the current file jadeddog Programming 3 06-11-2009 08:14 PM
sed: print section of file from string to end of file samyboy Linux - Newbie 4 02-26-2008 08:23 AM


All times are GMT -5. The time now is 08:21 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration