Sponsored Content
Top Forums Shell Programming and Scripting How to extract a text portion from a file Post 302332721 by summer_cherry on Friday 10th of July 2009 02:18:41 AM
Old 07-10-2009
hi , if your file is in fixed format that each section contains 5 lines, simply use below should be ok
Code:
sed -n '/xyz/{N;N;N;N;p;}' yourfile

otherise, may try below awk

Code:
awk '{
if($0 ~ /xyz/)
	flag=1
if(flag==1)
	print
if($0 ~ /end of text/)
	flag=0
}' yourfile

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Separate a portion of text file into another file

Hi, I have my input as follows : I have given two entries- From system Mon Aug 1 23:52:47 2005 Source !100000006!: Impact !100000005!: High Status ! 7!: New Last Name+!100000001!: First Name+ !100000003!: ... (4 Replies)
Discussion started by: srikanth_ksv
4 Replies

2. Shell Programming and Scripting

extract a portion of log file

hello, I want to grep the log file according to time and get the portion of log from one particular time to other. I can grep for individual lines by time but how should I print lines continuously from given start time till end till given end time. Appreciate your ideas, Thanks chandra (8 Replies)
Discussion started by: chandra004
8 Replies

3. Shell Programming and Scripting

extract date portion from file

Hi, I have a file where there is a date field (single line variable length file) how to extract just the date portion from it the position of date field may vary anywhere in the line but will always have the format mm-dd-yyyy for eg . xxxxxxxxxxxxxxx09-10-2006xxxxxxxxxxxxxxxxxxxx (5 Replies)
Discussion started by: misenkiser
5 Replies

4. UNIX for Dummies Questions & Answers

How to extract a portion of text from a log file

I am using Unix on Mac OS X 10.5.6. I am trying to extract the last entry of a log (text) file. As seen below, each log entry looks like the following (date and time change with each log entry): I want the script to extract everything quoted above, including the "===" dividers. ... (2 Replies)
Discussion started by: atilano
2 Replies

5. Shell Programming and Scripting

extract string portion using sed

Hi All I have 3 files as listed below and highlighted in bold the portions of the filenames I need to extract: TOS_TABIN218_20090323.200903231830 TOS_TABIN219_1_20090323.200903231830 TOS_TABIN219_2_20090323.200903231830 I tried source_tabin_name=`echo $fname | sed 's/_.*//'` but I... (6 Replies)
Discussion started by: santam
6 Replies

6. Shell Programming and Scripting

Extracting a portion of data from a very large tab delimited text file

Hi All I wanted to know how to effectively delete some columns in a large tab delimited file. I have a file that contains 5 columns and almost 100,000 rows 3456 f g t t 3456 g h 456 f h 4567 f g h z 345 f g 567 h j k lThis is a very large data file and tab delimited. I need... (2 Replies)
Discussion started by: Lucky Ali
2 Replies

7. Shell Programming and Scripting

parsing a portion of Data from a text file

Hi All, I need some help to effectively parse out a subset of results from a big results file. Below is an example of the text file. Each block that I need to parse starts with "Output of GENE for sequence file 100.fasta" (next block starts with another number). I have given the portion of... (8 Replies)
Discussion started by: Lucky Ali
8 Replies

8. Shell Programming and Scripting

How to extract portion of a string?

Hi Gurus, Would like to seek some help on how to extract a portion of string from log's output as shown below. Sample of raw data: piece handle=/test123/disk_dump/test123/df0_cntrl_PCPFCI20120404_68498 tag=TAG20120404T180035 comment=NONE piece... (13 Replies)
Discussion started by: superHonda123
13 Replies

9. Shell Programming and Scripting

Extract portion of data

Hi Gurus, I need some help in extracting some of these information and massage it into the desired output as shown below. I need to extract the last row with the header in below sample which is usually the most recent date, for example: 2012-06-01 142356 mb 519 -219406 mb 1 ... (9 Replies)
Discussion started by: superHonda123
9 Replies

10. UNIX for Beginners Questions & Answers

Extract a portion of string from each line in Linux

Hi I have to extract the destination path information from each record the file is of variable length so I will not be able to use the print command.The search should start on variable "destinationPath" and it should end at immediate "," also the first field has to be printed Input File:... (7 Replies)
Discussion started by: rkakitapalli
7 Replies
OSACOMPILE(1)						    BSD General Commands Manual 					     OSACOMPILE(1)

NAME
osacompile -- compile AppleScripts and other OSA language scripts SYNOPSIS
osacompile [-l language] [-e command] [-o name] [-d] [-r type:id] [-t type] [-c creator] [-x] [-s] [-u] [-a arch] [file ...] DESCRIPTION
osacompile compiles the given files, or standard input if none are listed, into a single output script. Files may be plain text or other compiled scripts. The options are as follows: -l language Override the language for any plain text files. Normally, plain text files are compiled as AppleScript. -e command Enter one line of a script. Script commands given via -e are prepended to the normal source, if any. Multiple -e options may be given to build up a multi-line script. Because most scripts use characters that are special to many shell programs (e.g., AppleScript uses single and double quote marks, ``('', ``)'', and ``*''), the command will have to be correctly quoted and escaped to get it past the shell intact. -o name Place the output in the file name. If -o is not specified, the resulting script is placed in the file ``a.scpt''. The value of -o partly determines the output file format; see below. -x Save the resulting script as execute-only. The following options are only relevant when creating a new bundled applet or droplet: -s Stay-open applet. -u Use startup screen. -a arch Create the applet or droplet for the specified target architecture arch. The allowable values are ``ppc'', ``i386'', and ``x86_64''. The default is to create a universal binary. The following options control the packaging of the output file. You should only need them for compatibility with classic Mac OS or for cus- tom file formats. -d Place the resulting script in the data fork of the output file. This is the default. -r type:id Place the resulting script in the resource fork of the output file, in the specified resource. -t type Set the output file type to type, where type is a four-character code. If this option is not specified, the creator code will not be set. -c creator Set the output file creator to creator, where creator is a four-character code. If this option is not specified, the creator code will not be set. If no options are specified, osacompile produces a Mac OS X format script file: data fork only, with no type or creator code. If the -o option is specified and the file does not already exist, osacompile uses the filename extension to determine what type of file to create. If the filename ends with ``.app'', it creates a bundled applet or droplet. If the filename ends with ``.scptd'', it creates a bun- dled compiled script. Otherwise, it creates a flat file with the script data placed according to the values of the -d and -r options. EXAMPLES
To produce a script compatible with classic Mac OS: osacompile -r scpt:128 -t osas -c ToyS example.applescript SEE ALSO
osascript(1), osalang(1) Mac OS X November 12, 2008 Mac OS X
All times are GMT -4. The time now is 10:24 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy