LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 07-08-2019, 03:57 PM   #1
esantillan
LQ Newbie
 
Registered: Jul 2019
Posts: 2

Rep: Reputation: Disabled
Sed command went super wrong, please help


Hi everyone, I'm very new at GNU Linux, so I used a sed command wrongly, I ended up messing all my most important files, the idea was to change all special characters in the file's names, but ended up changing all special characters inside the files.

This is the command:

Code:
sed -i 'y//aAaAaAaAeEeEiIoOoOoOuUnNcC/' Docs/superimportant_files/*
There are 1400 files, which have are .pdf and the other have are .doc

I need to undo this, but I can't. I need big help.
 
Old 07-08-2019, 03:59 PM   #2
esantillan
LQ Newbie
 
Registered: Jul 2019
Posts: 2

Original Poster
Rep: Reputation: Disabled
I haven't done anything else with those files, at all, since the dumb accident.
 
Old 07-08-2019, 04:03 PM   #3
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 1,205

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
The attempt to rerun the sed -i with swapped sides will likely fail, because it cannot distinguish between the produced destination characters and the destination characters that have already been there.
Restore from backup!

Last edited by MadeInGermany; 07-08-2019 at 04:07 PM.
 
Old 07-08-2019, 04:03 PM   #4
rtmistler
Moderator
 
Registered: Mar 2011
Location: MA, USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 8,064
Blog Entries: 13

Rep: Reputation: 3506Reputation: 3506Reputation: 3506Reputation: 3506Reputation: 3506Reputation: 3506Reputation: 3506Reputation: 3506Reputation: 3506Reputation: 3506Reputation: 3506
I'd start by making backups of what you do have, searching for any former good copies of the files, and setting them all aside so as to not cause more troubles.

Then I'd try the reverse of that command only on a copy of one file and see if it fixes it:
Code:
sed -i 'y/aAaAaAaAeEeEiIoOoOoOuUnNcC//' <filename>
Note that sed does NOT change your file names, it changes the contents of files. Use the rename(2) command instead.
 
Old 07-08-2019, 04:06 PM   #5
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.6
Posts: 3,831

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
You don't have a backup to restore from, then?

Backup your files before you try anything else.

man sed says
Code:
-i[SUFFIX], --in-place[=SUFFIX]
    edit files in place (makes backup if SUFFIX supplied)
Reverse the sed, perhaps?
Code:
sed -i.bak 'y/aAaAaAaAeEeEiIoOoOoOuUnNcC//' Docs/superimportant_files/*
Edit: rtmistler and MadeInGermany are quicker than I

Last edited by scasey; 07-08-2019 at 04:09 PM.
 
Old 07-08-2019, 06:56 PM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 18,148

Rep: Reputation: 2935Reputation: 2935Reputation: 2935Reputation: 2935Reputation: 2935Reputation: 2935Reputation: 2935Reputation: 2935Reputation: 2935Reputation: 2935Reputation: 2935
Both pdf and doc files are compressed, not plain text, so the damage is more than simply cosmetic. I agree with the sentiments in post #3.
 
  


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
transferring large files on usb 3.1 goes from super fast to super slow chripy811 Linux - Hardware 8 04-03-2019 05:25 PM
LXer: Where Google Went Wrong with Android? and Where Nokia & Intel Went Right? LXer Syndicated Linux News 2 10-26-2010 07:22 AM
Super useryes! Super Cow? vyver Ubuntu 10 10-24-2010 07:29 PM
My laptop hang out after RHEL 5.2 server installation, What went wrong? Please help maxudit007 Linux - Newbie 1 06-07-2008 02:13 PM
nfs write == super slow; read == super fast - problem? BrianK Linux - Networking 4 08-23-2007 10:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:19 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