rm * .bam
Undo a shell script when input file is overwritten
Hi,
Is it possible to redo a shell script? I overwrote my files running a shell script
I ran nohup sh 1.sh
But my output file was same as the input file, so it overwrote my input file
Thank you
• 3,108 views
•
link
3 answers
- restore input from backup
- recompute input
there's not much else you can do... sooner or later, that happens to everybody
• 0 views
•
link
• 0 views
•
link
Lol...don't want to delete more files
• 0 views
•
link
Your input file is gone. Unless you have a backup somewhere, there is no way to restore it or "redo" the script.
Pro tip: make sure your input files are read-only (chmod -w) to avoid loss of data.
• 0 views
•
link
As others have said, your data is long gone, unless:
- You have the original input data, and can simply recompute it easily enough.
- Your server/SysAdmin has configured regular snapshots, but this isn't that common, and would probably only get you to whereever you were yesterday.
There's no such thing as a recycle bin on Unix, so when you delete stuff - you really delete stuff.
• 0 views
•
link
Log in to answer this question.
Did you try ctrl-z?
ctrl+z will interrupt the running of the script. The script finished running
Question unclear, please elaborate.
If your question fits in one sentence you did not explain it enough
I ran a shell script using: nohup sh 1.sh But my output file was same as the input file, so it overwrote my input file. What should i do?
Changed the title to make it more specific, added the additional information provided in the comments to the original question, cleaned up comments, and moved comments to answer so you can mark them as accepted.
Thank you for your help. I don't have backup of file but i am still optimistic. I used zcat and gzip to merge and zip the files using : zcat file1.fastq.gz file2.fastq.gz | gzip -c > file1.fastq.gz
You could just do
cat file1.fastq.gz file2.fastq.gz > merged.fastq.gz. There is no need to zcat/gzip again.zcatalready concatanates compressed files, there is no need forgzipin this command:Ok, thanks. But my file1.gz is empty now
I found this link : https://superuser.com/questions/292728/critical-gzip-mistake-help-how-to-undo-gzip-r/1426042#1426042 Will gzip -r work? Thanks
Sorry, did not pay attention. Use
catto concatenate:Also do not write to a file with identical name as the input.