Sponsored Content
Full Discussion: Extract fragments from file
Top Forums Shell Programming and Scripting Extract fragments from file Post 302897824 by black_fender on Wednesday 16th of April 2014 08:41:41 AM
Old 04-16-2014
I have a new issue on this topic.
I've settled to this awk expression :

Code:
targetFile=log.xml
targetItem="string 1 string2"
awk '/<mi>/ || s {s=s?s"\n"$0:$0} /<\/mi>/{if (s ~ Item) print s; s=""}' Item=$targetItem $targetFile

I have problems in declaring Item variable which takes its value from $targetItem when $targetItem contains spaces. I tried to declare targetItem like this :
Code:
targetItem="string1\ string2"

but it doesn't work.
The awk expression takes "string2" as a value for $targetFile ....


...Nevermind I forgot to use double quotes :
Code:
awk '/<mi>/ || s {s=s?s"\n"$0:$0} /<\/mi>/{if (s ~ Item) print s; s=""}' Item="$targetItem" $targetFile

Applogize for taking your time with this.

Last edited by black_fender; 04-16-2014 at 09:55 AM.. Reason: Posted by mistake
 

8 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

fragments in Solaris 8

When discussing inodes and data blocks, I know Solaris creates these data blocks with a total size of 8192b, divided into eight 1024b "fragments." It stores data in "contiguous" fragments and solaris doesn't allow a file to use portions of two different fragments. If the file size permits, then the... (4 Replies)
Discussion started by: manderson19
4 Replies

2. Solaris

ipfilter blocking ip fragments

For some reason ipfilter is blocking inbound fragmented ip packets (the packets are larger than the interface's MTU) that are encapsulating UDP segments. The connection works, so I know ipfilter is letting some traffic through, it is just a lot slower than it should be. Rules that allow the... (3 Replies)
Discussion started by: ilikecows
3 Replies

3. IP Networking

Solaris 11 Express NAT/Router IP Fragments

Upon replacing my linux router/server with a Solaris one I've noticed very poor network performance. The server itself has no issues connecting to the net, but clients using the server as a router are getting a lot of IP fragments as indicated from some packet sniffing I conducted. Here was my... (3 Replies)
Discussion started by: vectox
3 Replies

4. Shell Programming and Scripting

Create shell script to extract unique information from one file to a new file.

Hi to all, I got this content/pattern from file http.log.20110808.gz mail1 httpd: Account Notice: close igchung@abc.com 2011/8/7 7:37:36 0:00:03 0 0 1 mail1 httpd: Account Information: login sastria9@abc.com proxy sid=gFp4DLm5HnU mail1 httpd: Account Notice: close sastria9@abc.com... (16 Replies)
Discussion started by: Mr_47
16 Replies

5. Shell Programming and Scripting

Extract rows from file based on row numbers stored in another file

Hi All, I have a file which is like this: rows.dat 1 2 3 4 5 6 3 4 5 6 7 8 7 8 9 0 4 3 2 3 4 5 6 7 1 2 3 4 5 6 I have another file with numbers like these (numbers.txt): 1 3 4 5 I want to read numbers.txt file line by line. The extract the row from rows.dat based on the... (3 Replies)
Discussion started by: shoaibjameel123
3 Replies

6. Shell Programming and Scripting

How to extract start/end times from log file to CSV file?

Hi, I have a log file (log.txt) that which contains lines of date/time. I need to create a script to extract a CSV file (out.csv) that gets all the sequential times (with only 1 minute difference) together by stating the start time and end time of this period. Sample log file (log.txt) ... (7 Replies)
Discussion started by: Mr.Zizo
7 Replies

7. Shell Programming and Scripting

Extract sentence and its details from a text file based on another file of sentences

Hi I have two text files. The first file is TEXTFILEONE.txt as given below: <Text Text_ID="10155645315851111_10155645333076543" From="460350337461111" Created="2011-03-16T17:05:37+0000" use_count="123">This is the first text</Text> <Text Text_ID="10155645315851111_10155645317023456"... (7 Replies)
Discussion started by: my_Perl
7 Replies

8. Shell Programming and Scripting

Why the results of these two code fragments are not the same?

Code 1: #!/bin/sh for arg1 in "$@" do counter=0 for arg2 in "$@" do if && then counter=$((counter+1)) continue fi (8 Replies)
Discussion started by: johnprogrammer
8 Replies
Audio::MPD::Common::Item(3pm)				User Contributed Perl Documentation			     Audio::MPD::Common::Item(3pm)

NAME
Audio::MPD::Common::Item - a generic collection item VERSION
version 1.120881 SYNOPSIS
my $item = Audio::MPD::Common::Item->new( %params ); DESCRIPTION
Audio::MPD::Common::Item is a virtual class representing a generic item of mpd's collection. It can be either a song, a directory or a playlist. Depending on the params given to "new", it will create and return an Audio::MPD::Common::Item::Song, an Audio::MPD::Common::Item::Directory or an Audio::MPD::Common::Playlist object. Currently, the discrimination is done on the existence of the "file" key of %params. METHODS
my $item = Audio::MPD::Common::Item->new( %params ); Create and return either an Audio::MPD::Common::Item::Song, an Audio::MPD::Common::Item::Directory or an Audio::MPD::Common::Playlist object, depending on the existence of a key "file", "directory" or "playlist" (respectively). AUTHOR
Jerome Quelin COPYRIGHT AND LICENSE
This software is copyright (c) 2007 by Jerome Quelin. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.14.2 2012-04-01 Audio::MPD::Common::Item(3pm)
All times are GMT -4. The time now is 08:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy