Programming :: Extracting Last Section Of File (Separated By Hashes)

Feb 22, 2011

I have a file which looks something like this:

##########
some
text
text also includes empty lines
##########
some
more
text
##########

Basically all sections are separated by 10 hashes and I need to somehow only print all lines in the last section (the "some more text" part in the example above"). I tried all kind of things with sed and awk but I didn't find any way to identify the last "section".

View 8 Replies


ADVERTISEMENT

Programming :: Extracting Block Of Text From Log File?

Nov 22, 2010

I have a log file and want to extract all blocks of text that start with START and ends with END. Each block is 5 lines.

Code:
--- START
blah blah blah

[code]...

View 1 Replies View Related

Programming :: Append A Block Of Text Into A Particular Section Of A File?

Mar 16, 2010

So I have file which looks something like this:

cat .opera/operaprefs.ini
Code:
[User Prefs]
Language Files Directory=

[code]...

View 1 Replies View Related

Programming :: Sort Hash Of Hashes By Value In Perl?

Dec 1, 2010

I have a hash of hashes and I need to sort this by value and write to a javascript array file..Currently I am using the following

foreach my $key(sort { keys %{$trans{$a}} <=> keys %{$trans{$b}}} keys %transmission)
{
foreach my $role(sort {$trans{$key}{$a} cmp $trans{$key}{$b}} keys %{$trans{$key}})

[code]...

View 2 Replies View Related

Programming :: Perl - Pointers To Arrays From Hashes?

Feb 18, 2010

I'm trying to figure out how to code for this specific type of instance - I want to use a hash and have the key be a reference to an array, and not use the key in the standard way of it being a scalar. Basically, I have a large output that I need to process line by line, and rather have access to it as an array than a big block in a scalar. For the big block hash as a scalar I would do -

Code:
foreach $CONTROLLER (<CONTROLLER_LIST>) {
$ALL_DISKS{$CONTROLLER} = `ssh -n <commands>`;
}

Now I know I could take the scalar and split it to another array after the fact like -

Code:
@TEMP_HOLD = split (/s+/,$ALL_DISKS{$CONTROLLER});

How would I code it that I would have access to the key information as an array and not a scalar? I know it needs to be a pointer and we're going to have -> in there somewhere, but not sure how to approach it. Some of the documentaiton I've been reading about referencing I've found a little confusing so far, and trying to figure out how to use them in context of what I'm working on.

View 1 Replies View Related

Programming :: Compare Files With Fields Separated With ':'?

Jul 16, 2011

Dear expertsI have files like

ABD : 5869 events, relative ratio : 1.173800E-01 , sum of ratios : 1.173800E-01
VBD : 12147 events, relative ratio : 2.429400E-01 , sum of ratios : 3.603200E-01
SDF : 17000 events, relative ratio : 3.400000E-01 , sum of ratios : 7.003200E-01

[code]....

View 3 Replies View Related

Programming :: Perl - Store And Access An Array In A Hash Of Hashes?

Jul 7, 2010

I am in need of some syntax help. I'm trying to figure out how to store and retrieve an array out of a hash of hashes. For this example, I'm trying to access the city list for a particular state for a particular country. I understand I could do a join and split on the hash key to combine Country and State, but trying to keep things separated.The code I have gets in all the information for the Countries, and states, and gets the list of cities together, no problem. I store all the city names in an array, then make an anonymous pointer to the array for the hash, like this - $MY_CITIES{$COUNTRY}{$STATE} = [@CITIES]I believe that syntax is correct, or is it? What I'd like to do is I need to cycle through every hash to find if a city exists or not. If it exists in 3 states, then it should print 3 times. Here is the code block to search -

Code:
for $COUNTRY (@LIST_OF_COUNTRIES) {
for $STATE ( keys %MY_CITIES{$COUNTRY){$STATE} ) {

[code]...

View 4 Replies View Related

Programming :: Merge Multiple Line With Semicolon Separated

Mar 29, 2010

I have a script generating some containing multiple lines. But I want to merge all lines using comma separated.

View 6 Replies View Related

Programming :: Converting Date Format In A Comma Separated Field?

Apr 9, 2010

I am in the process of learning some scripting, however I am running into a roadblock in specifying a certain time format in the array. Ideally I would like to use Here are the lines of text that I am interrogating:

1123,3/25/2010,00:14 Thu,33229
1124,3/26/2010,13:30 Fri,33230
1125,3/27/2010,04:49 Sat,33231

[code]...

View 2 Replies View Related

General :: Convert Tab Separated File To Simple X-Y Chart

Aug 27, 2009

I wrote a script which analysis apache logs. This script generates a tab separated data file. There is two columns in the data. The first column is a file name accessed from remote. The second column shows how many times a file access.

I am looking for a linux command drawing a chart corresponding data.of course, I know that I can draw the chart in OpenOffice Calc. That's not what I need. Because there is some steps to do for a simple chart drawing. If there is a command line tool, then I can write a script that drawing a chart when the data file is updated.

View 6 Replies View Related

Fedora Security :: Generating Password Hashes Compatible With FC11/sha-512 Shadow File?

Jul 3, 2009

I've been trying to write php or perl code to generate the sha-512 password hashes in fedora. I've been unable to do the hashing which is encoded in the shadow file on fedora core 11. Does anyone have php or perl code which provides the hashing algorithm. (All of my attempts result in the encrypted hashing being longer than 86 character -- the length that crypt says the sha-512 should be)

View 3 Replies View Related

OpenSUSE Install :: Immutable Section Of HDD + Differencing Section?

Jul 8, 2010

You maybe know that VirtualBox has an "immutable" feature for HDD images. I.e. setup the system, if the stuff is in place, you can set the image to IMMUTABLE to prevent any changes to the image. Differences are written to a separated image. So on the next boot you'll see that all the (unintended) changes are gone and the "old" system is up & running again. I run an old SuSE 10.3 on a write-protected SD-IDE-Adapter. Changing and playing with RPMs is a mess due to around 50 changes I had to do to make that work. Is there any option to mount an SD-card as RO and having all the changes written to e.g. /dev/sda3? To make it clear: I thought about something like a RAID-X system, but could not find any description on how to setup a raidtab.

View 3 Replies View Related

General :: Extracting Tar File: Cannot Open: No Such File Or Directory?

Jul 19, 2010

I have a remote Debian 5 machine on which I'm trying to extract a tar-file (Django 1.2.1, but that's unimportant). The first 1300 or so files extracts just fine (of about 2800 in total), after which errors liketar: Django-1.2.1/tests/urls.py: Cannot open: No such file or directoryshows up for the rest of the files, finally ending up with atar: Error exit delayed from previous errorsI use the commandtar xzvf Django-1.2.1.tar.gzI've also tried with sudo (but I'm extracting in my home directory, which I should obviusly have permissions to use without). I've tried gunzipping first (runs flawlessly) and then running tar xvf, but to no avail. I've fetched the file using wget:

View 1 Replies View Related

Programming :: Extracting URLs From Strings?

Jun 28, 2009

I have a PHP script written that is checking a string to see if it contains a link in it (i.e. a URL). I have the following if statement, that uses 3 possible regular expressions to determine if there is a link or not.

Code:
// check if we found a link
// links are denoted by strings that:
// - contain http://
// - contain www.*.*

[Code]....

I'm not convinced yet that writing a shell script to do this is the best course of action. If someone is capable of doing this with a Perl or a Python script that's fine too. If you want to make it super high performance and write it in assembly

View 1 Replies View Related

Programming :: Extracting Columns In Particular Order?

Jun 9, 2010

Say I have a text file with10 columns. I need to reorder them based on a list of column numbers that will reorder them.

My problem is this:

If I want to cut out 5 columns (columns 1,2,3,9,10) in the order 1,10,2,9,3 then I have tried using:

Code: cut -f1,10,2,9,3 my_file.txt > reordered_file.txt But this just extracts the columns in order as if I used:

Code: cut -f1,2,3,9,10 my_file.txt > reordered_file.txt How can I cut these columns and place them into the new file in the order I specify?

While this might seem quite trivial, I will actually need to do this for a file containing ~14000 columns with ~12000 columns that I need to extract in a particular order.

View 2 Replies View Related

Programming :: C++: Extracting Data From A NESTED STL Map?

Feb 8, 2011

Code for insertion of data:

Code:

#include <map>
#include <iostream>
int main ()

[code]....

I don't know how to fetch the data from the nested map here.

View 5 Replies View Related

Programming :: Extracting Integers From A String?

Nov 8, 2010

I have a string, like file223a3b5. How can I extract the number beginning after "file" and ending before "a"?

View 3 Replies View Related

Fedora :: Extracting Tar Gz File ?

Aug 9, 2011

My OS is Fedora 14 - 64bit. I want to extract and install this file "LEXMARK-INKJET-LEGACY-wJRE-1.0-1.x86_64.rpm.sh.tar.gz". At the moment this is in the download box in the top left corner of my monitor.

I have tried several ways, but all I get is Command Line Output. Gzip:stdin: unexpected end of file./bin/gtar: unexpcted EOF archive. /bin/gtar: error is not recoverable: exiting now.

View 1 Replies View Related

Ubuntu :: Two IDLE Icons In Application Programming Section?

Feb 16, 2011

For some reason I have two IDLE icons in my application programming section:

IDLE
IDLE(using python-2.6)

Both are the exact same versions, and I'm not sure if I need both. I understand that ubuntu runs on 2.6 so I'm a bit hesitant to just delete one without checking here first.

View 1 Replies View Related

Programming :: Deadlock Due To Crash Inside Critical Section?

May 12, 2011

The following two pieces of codes share printing to stdout with a POSIX semaphore /dev/shm/sem.abcd

sema1.c:

Code:
int j;
sem_t *sem = sem_open( "/abcd", O_CREAT, S_IRUSR|S_IWUSR, 1 );
j = 0;
while (j < 100) {

[Code].....

If started at the same time, the first will finish in about 10 seconds; the second 20 secs.

What I want to ask is, if the first program crashes at Checkpoint A, then B will never gets to continue, then normally how do programmers avoid this kind of deadlock due to crashes inside the critical section?

View 3 Replies View Related

Programming :: Extract Dwarf Information Debug A Section?

May 10, 2011

I would like to extract debug information but I have some problems. For example, I have a executable a.out...

Quote:

nm -f sysv a.out | grep ".global_var" >vars.txt

With this command I extract all my variables. All of them are in .global_var section, and it give me follow information:

Quote:

CAN_station_n |08073258| D | OBJECT|00000001| |.global_var
CONTROLend |080732a7| D | OBJECT|00000001| |.global_var

[code]....

Well, I have only address of my vars, but I would like to know type var or struct of the variables. With dwarf dump I have all of information, but it is a mess...

Quote:

<1><117bc>: Abbrev Number: 32 (DW_TAG_variable)
<117bd> DW_AT_name : (indirect string, offset: 0x153d): draw_limits
<117c1> DW_AT_decl_file : 128
<117c2> DW_AT_decl_line : 207

[code]...

Is there any parser or way to put in order this information?? create a file with the follow information:

name of var - address - type - size - struct or not

View 5 Replies View Related

Programming :: Underscores In Standard Functions, An Example Section From Cat.c Is Included

Sep 4, 2010

From cat.c in GNU coreutils:

Code:
void
usage (int status)
{
if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.

[Code]...

I don't remember ever seeing this in any examples I've ever seen, so I'm sure I've never seen an explanation of this.

View 1 Replies View Related

Programming :: Extracting Auditing Info Using Awk System And Ausearch?

Aug 25, 2010

I'm a linux newbie and scripting novice and I'm trying to pull auditing info and dump it into a file. I made some login changes so it would get audited but I don't want to have to sift through the log to see who the user was and what was done. This is what I have below here and I can't seem to get it to extract the info want using the event id. The "ausearch -a $10" from the script should get it from the 10th column but it's not working.If I can get this to work I would like to add additional aureport options.

#!/bin/bash
yyyy=`date "+%Y"`
mm=`date "+%m"`

[code]...

View 6 Replies View Related

Programming :: Searching Thunderbird Emails & Extracting Information

Jun 8, 2010

I have a load of emails in my Thunderbird trash folder and some of them (all with a similar subject) I want to extract the email address for them and put in a text file. I have located the trash file but it seems that it is just a big flat file with a concatenation of all my emails in it, varying number of header lines etc etc - ie, something which really doesn't seem to suit awk, sed, grep etc.Does anyone know of any way this might be accomplished, or any third party tools which may help?

View 1 Replies View Related

General :: Sed/awk - Remove Section From File

Oct 26, 2010

I have a file like this:

I would like to remove a section between [first] and [second]:

Is almost what I want. I would like the section header to say in place.

Desired output:

View 3 Replies View Related

Software :: Split A File By Section?

Aug 27, 2010

How would I go about splitting a file by section? Imagine the file looks like this:

Lots of text 1
Lots of text 2
[HEY, SPLIT HERE]

[code]....

I want to use a command that would split this file, but look for the text "[HEY, SPLIT HERE]" to get the split points.

View 2 Replies View Related

Ubuntu :: Error While Extracting ZIP File Using GUI

May 8, 2010

I have this file that is in ZIP. I can open it and browse the files inside via archive manager. But extracting it gives me an error. When using GUI it says that 'ERROR while extracting files'
and in command line when I command:
unzip -q myfile.zip

It display this errors

file #2109: bad zipfile offset (local header sig): -2122072556
file #2110: bad zipfile offset (local header sig): -2121511988
file #2111: bad zipfile offset (local header sig): -2121511886
file #2112: bad zipfile offset (local header sig): -2121375823
file #2113: bad zipfile offset (local header sig): -2121310073
file #2114: bad zipfile offset (local header sig): -2121282474
file #2115: bad zipfile offset (local header sig): -2121107851
file #2116: bad zipfile offset (local header sig): -2121015601
file #2117: bad zipfile offset (local header sig): -2120957317
file #2118: bad zipfile offset (local header sig): -2120906286
file #2119: bad zipfile offset (local header sig): -2120906193

I just need to find a way to extract my file.

View 4 Replies View Related

Ubuntu :: Error Extracting File From Zip

Oct 9, 2010

I'm trying to extract a file from a zipped archive, and receive an error message saying "caution: filename not matched:".

I suspect the route cause of this is that the original filename contained accented characters (which now show as question marks in the zipped filename). I've tried renaming the file in the archive, but get the same error.

I'm using 9.10 (Karmic).

View 3 Replies View Related

Red Hat / Fedora :: Extracting Data From A Xml File Using C?

Feb 11, 2010

I am trying to extract data from the xml file using c coding. here is the sample code. this code gets compiled with errorfree. but the call back functions start and end are not invoked. coding:

#include<stdio.h>
#include<string.h>
#include<expat.h>

[code]...

View 1 Replies View Related

Ubuntu :: Broken Shortcuts For Netbeans On Section Applications -> Programming?

Feb 16, 2010

I have two broken shortcuts for Netbeans on section Applications -> Programming.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved