LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-25-2014, 04:45 PM   #1
zetrotrack000
Member
 
Registered: Dec 2011
Posts: 401

Rep: Reputation: Disabled
script for cleaning firefox history items


Hi
I am trying to create a script which can remove certain terms from firefox history (e.g microsoft, hell etc.). I have created following script:
Code:
#!/bin/bash
sed '/microsoft/gotohell/' /home/<user>/.mozilla/firefox/<profile-dir>/places.sqlite
sed '/oracle/ms-destination/' /home/<user>/.mozilla/firefox/<profile-dir>/places.sqlite
.
.
##Note: This is just an example.
But, if we look inside places.sqlite, it saves entire location of url and removing only one word is looking strange to me. What do you think, am I doing right or how can I make it correct.
Regards

Last edited by zetrotrack000; 11-26-2014 at 06:03 AM.
 
Old 11-26-2014, 08:18 AM   #2
zetrotrack000
Member
 
Registered: Dec 2011
Posts: 401

Original Poster
Rep: Reputation: Disabled
No answer! thats strange...
One more option is ask 'sed' to delete the entire line which contains the <word>.
 
Old 11-26-2014, 09:20 AM   #3
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Code:
sed -i 'X d' /path/to/file
where X is the offensive line number.
You can find the line number using grep (I'm not that clever with sed, but I guess it can show line numbers also, I just don't know how that's done) as in
Code:
grep <string> /path/to/file -n
then use that line number in the first sed command.
 
Old 11-26-2014, 11:50 AM   #4
zetrotrack000
Member
 
Registered: Dec 2011
Posts: 401

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Habitual View Post
Code:
sed -i 'X d' /path/to/file
where X is the offensive line number.
You can find the line number using grep (I'm not that clever with sed, but I guess it can show line numbers also, I just don't know how that's done) as in
Code:
grep <string> /path/to/file -n
then use that line number in the first sed command.
First finding the line number and then giving it to sed, i think this would kill the purpose of the script. I think following command would be better:
Code:
sed -i '/pattern/d' filename
 
Old 11-26-2014, 02:47 PM   #5
zetrotrack000
Member
 
Registered: Dec 2011
Posts: 401

Original Poster
Rep: Reputation: Disabled
However, this may cause more problems and currupt places.sqlite as the target word may appear in bookmarks and other items in this file.
 
Old 11-26-2014, 07:18 PM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,285

Rep: Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165
Of course you'll corrupt the table. Use sqlite commands - dump the schema to find the fields/key, then the table to see what's in it. Use update or delete as desired.
Can all be scripted, but firefox will need to be inactive else the table will be locked.

Plenty of tutorials online.
 
Old 11-27-2014, 12:19 PM   #7
zetrotrack000
Member
 
Registered: Dec 2011
Posts: 401

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by syg00 View Post
Of course you'll corrupt the table. Use sqlite commands - dump the schema to find the fields/key, then the table to see what's in it. Use update or delete as desired.
Can all be scripted, but firefox will need to be inactive else the table will be locked.

Plenty of tutorials online.
Hmm... Thanks. lets see what I can do with sqlite commands.
 
  


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
Need a script for automatically cleaning up /var/spool/cups directory everyday thamim123 Linux - General 2 04-08-2014 10:44 AM
[SOLVED] Bash: Script for cleaning Voicemails from Asterisk. Mortuus Programming 4 04-17-2010 02:56 AM
Cleaning up my first bash script altup Linux - Newbie 2 09-15-2009 04:26 PM
script for cleaning log Imranteli Linux - Newbie 3 09-11-2009 12:25 AM
cleaning the readability of this ruby script hedpe Programming 1 12-26-2006 03:46 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:47 AM.

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
Open Source Consulting | Domain Registration