LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 10-12-2012, 10:38 AM   #1
jim.thornton
Member
 
Registered: May 2007
Posts: 330

Rep: Reputation: 17
I need help searching for values in a file.


I am in the process of migrating a site. The site was running Joomla 1.0.x and there were about 84 pages of content. The site had defined a custom HTML Title for each page and it was saved into a db with the following structure:

Code:
INSERT INTO `jos_content` (`title`, `attribs`) VALUES
The `attribs` field contains a whole bunch of parameters int he format like this:

Code:
pageclass_sfx=\nback_button=\nitem_title=0\nlink_titles=\nintrotext=0\nsection=0\nsection_link=0\ncategory=0\ncategory_link=0\nrating=0
The attribute I'm looking for is: html_title

I have created the regex that will find the value that I want out of each entry:
Code:
^html_title=.*$
However, I can't figure out how to parse the data. Currently I have exported those two fields only into a .sql file. So I don't currently have it in a mysql database.

Could someone please help me come up with some code that would create a text file with a list as follows:
title: html_title (with html_title being the only value extracted out of attribs)

I would appreciate any help I can get please.
 
Old 10-12-2012, 02:08 PM   #2
sinu_nayak2001
Member
 
Registered: Oct 2009
Location: India
Distribution: Puppy Linux, Wary 530.
Posts: 31

Rep: Reputation: 20
Have you tried 'cut' command? or awk?
 
Old 10-12-2012, 02:54 PM   #3
jim.thornton
Member
 
Registered: May 2007
Posts: 330

Original Poster
Rep: Reputation: 17
there are 84 instances of the title field and the attribs field.

I'm not sure how to create a script that will read the file and loop through each instance and then extract what I need.
 
Old 10-12-2012, 11:19 PM   #4
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,541

Rep: Reputation: 1919Reputation: 1919Reputation: 1919Reputation: 1919Reputation: 1919Reputation: 1919Reputation: 1919Reputation: 1919Reputation: 1919Reputation: 1919Reputation: 1919
Hey Jim ... could you supply an example with a few lines and also have them include the required data (unlike your current example)?

This does seem like a fairly easy task but we need to better understand the data if we are to assist with a solution.
 
Old 10-13-2012, 12:19 AM   #5
jim.thornton
Member
 
Registered: May 2007
Posts: 330

Original Poster
Rep: Reputation: 17
Thanks for the reply. Don't worry about it. Usually my questions get answered in a few minutes because of the amount of traffic on this forum so when I went a lot of the day without a response, I figured one wasn't coming.

As a result I ended up doing it semi-manually. I opened the SQL file in a text editor that supports regular expressions. I then created a regex to find everything before html_title and replaced it with nothing (essentially deleting it) and then I created a regex to find everything after html_title and replaced it with nothing. I then just copy/pasted the results to where I needed them.
 
Old 10-13-2012, 02:50 AM   #6
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,541

Rep: Reputation: 1919Reputation: 1919Reputation: 1919Reputation: 1919Reputation: 1919Reputation: 1919Reputation: 1919Reputation: 1919Reputation: 1919Reputation: 1919Reputation: 1919
Well I am not sure about others, but as the replies prior to mine were 0400 you might see why some of us had not seen the question yet

If you are happy with your solution then by all means marks as SOLVED, but should you like an alternative for the future I would still like to see some data
 
Old 10-13-2012, 06:39 AM   #7
jim.thornton
Member
 
Registered: May 2007
Posts: 330

Original Poster
Rep: Reputation: 17
not sure what you mean by by 0400.???

As for the solution, I'll just mark it solved because I think the way I did it was easier than writing a script in the end anyway.
 
Old 10-13-2012, 08:09 AM   #8
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,541

Rep: Reputation: 1919Reputation: 1919Reputation: 1919Reputation: 1919Reputation: 1919Reputation: 1919Reputation: 1919Reputation: 1919Reputation: 1919Reputation: 1919Reputation: 1919
0400 -- 4 am. in the morning
 
Old 10-13-2012, 04:59 PM   #9
jim.thornton
Member
 
Registered: May 2007
Posts: 330

Original Poster
Rep: Reputation: 17
Thanks... I thought you were talking permissions or something. As for the time, no worries I wasn't complaining. It's just that most of my questions are answered within a hour but this one was about 8 or 9 hours. Hey... I'm happy to get any help, so I'm not complaining at all.
 
  


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
Searching for values mikes88 Programming 5 01-21-2012 07:13 AM
Searching content of the file using File Browser Nautilus susja Linux - Newbie 4 05-28-2011 06:25 PM
Searching .txt file for (specific) strings and printing them to new file Hb_Kai Linux - General 7 02-18-2010 09:09 AM
Searching for numeric values in PHP TheBeli Programming 5 04-17-2008 03:55 AM


All times are GMT -5. The time now is 09:31 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration