Sponsored Content
Top Forums Shell Programming and Scripting Jump to a specific place in a file? Post 302213997 by jim mcnamara on Friday 11th of July 2008 04:31:46 PM
Old 07-11-2008
Code:
pattern1="fox"
pattern2="dog"
awk -v pat1="$pattern1" -v pat2="$pattern2" \ 
           'BEGIN{ found==0}
         if(found==0)         
            {if(index($0, pat1)> 0) {found=NR} }
         if(found>0  && index($0, pat2)>0) {print $0} } ' inputfile


This code starts looking for "dog" only after it finds "fox".
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

insert file 1 at a specific place of file 2

Hello, I need to search in file2 for class A : public B { and insert right after that the content of file1. I am a bit lost as to which tools (which bash functions, awk...). I should use. Thanks for some directions here. Regards (1 Reply)
Discussion started by: JCR
1 Replies

2. Shell Programming and Scripting

Splitting av file in 2 at specific place based on textpattern

I have a file that I want to split in 2 (with Bourne shell sh) preferably. The file consists of groups of lines separated by newline. The file can vary in length, so I need to check number of groups of text. Here's an example ====EXAMPLE START==== #fruit banana #color yellow #surface smooth... (0 Replies)
Discussion started by: borgeh
0 Replies

3. Shell Programming and Scripting

[bash] jump from one txt file to another

Hi all, I need to create a bash script that reads a txt file on a remote (Windows 2003) server, gets the IP-addresses out of it and then fetches the folders to copy out of another txt file. (all files are auto-generated) The IP addresses that don't have a folder_list file should be ignored. At... (31 Replies)
Discussion started by: laurens
31 Replies

4. Shell Programming and Scripting

Read from file specific place in file using inode

Hello, I am using tcsh on AIX. I would like to write a script that does the following: 1. given an inode, how do I find exactly the name of the file? I know I could do this using ls -i | grep <inode> but it returns: <inode> <filename>. I need some string manipulation or something to... (1 Reply)
Discussion started by: lastZenMaster
1 Replies

5. Shell Programming and Scripting

script for inserting line at specific place in file

I use zentyal for my server admin, which is great but zentyal auto-generates config file on boot and hence overwrites any changes made directly to config files. In order to allow multiple user access to a MS ACCESS database, I need to customise the smb.conf file and add the following line to the... (9 Replies)
Discussion started by: barrydocks
9 Replies

6. Shell Programming and Scripting

place cursor in specific coordinates

Hi, I have this problem on how to place the cursor in a text editor (for example: pico). I made this script that would attach comments to a script file then open the script file, I would like to know how to place the cursor in a specific place, for example at the end of the comments, ... (1 Reply)
Discussion started by: lechelle
1 Replies

7. UNIX for Advanced & Expert Users

vimdiff jump to other file or switch windows

This took me quite awhile to find so I wanted to share this with other people. To switch windows in vimdiff or to navigate windows in vimdiff or to change windows in vimdiff try the following: The ":vertical" command can be inserted before another command that splits a window. ... (0 Replies)
Discussion started by: cokedude
0 Replies

8. Shell Programming and Scripting

How to merge variable data from another file into specific place?

Hello, I'm trying to create multiple commands using a variable input from another file but am not getting any successful results. Basically, file1.txt contains multiple lines with single words: <file1.txt> yellow blue black white I want to create multiple echo commands with these... (8 Replies)
Discussion started by: demmel
8 Replies

9. Shell Programming and Scripting

Unable to get the Specific column with 2 decimal place

Hi, I have an issue converting decimal places of a particular column, i am using below script to get the output, but the output is not generating in desired format. awk -F"," 'BEGIN{OFS=","}{if(NR==0)getline;if ($7 != "") {if ($7 > 0) $7=$7/100 ; {printf "%.2f"... (3 Replies)
Discussion started by: rramkrishnas
3 Replies

10. Shell Programming and Scripting

awk to place specific contents filename within text file

I am trying to use awk to place the contens of a filename in $1 and $2 followed by the data in the text file. Basically, put the filename within the text file. There are over 1000 files in the directory and as of now each file is saved with a unique name but it is not within the file. Thank you... (10 Replies)
Discussion started by: cmccabe
10 Replies
GEOM_FOX(4)						   BSD Kernel Interfaces Manual 					       GEOM_FOX(4)

NAME
geom_fox -- GEOM based basic disk multipathing SYNOPSIS
To compile this driver into the kernel, place the following line in your kernel configuration file: options GEOM_FOX Alternatively, to load the driver as a module at boot time, place the following line in loader.conf(5): geom_fox_load="YES" DESCRIPTION
The intent of the geom_fox framework is to provide basic multipathing support to access direct access devices. Basic in the above sentence should be read as: geom_fox only provides path failover functionality, not load balancing over the available paths etc. Using suitable hard- ware like SCSI or FibreChannel disks it is possible to have multiple (typically 2) host bus adapters access the same physical disk drive. Without a multipathing driver the FreeBSD kernel would probe the disks multiple times, resulting in the creation of multiple /dev entries for the same underlying physical device. A unique label written in the GEOM label area allows geom_fox to detect multiple paths. Using this information it creates a unique da#.fox device. The geom_fox device is subsequently used by the FreeBSD kernel to access the disks. Multiple physical access paths ensure that even in case of a path failure the FreeBSD kernel can continue to access the data. The geom_fox driver will disallow write operations to the underlying devices once the fox device has been opened for writing. EXAMPLES
o geom_fox needs a label on the disk as follows in order to work properly: "0123456789abcdef0123456789abcdef" "GEOM::FOX <--unique--id-->" For the unique ID 16 bytes are available. The ``GEOM::FOX'' is the magic to mark a geom_fox device. The actual labelling is accomplished by echo "GEOM::FOX someid" | dd of=/dev/da2 conv=sync For FibreChannel devices it is suggested to use the Node World Wide Name (Node WWN) as this is guaranteed by the FibreChannel standard to be worldwide unique. The use of the Port WWN not recommended as each port of a given device has a different WWN, thereby confusing things. The Node WWN can be obtained from a verbose boot as in for example isp1: Target 1 (Loop 0x1) Port ID 0xe8 (role Target) Arrived Port WWN 0x21000004cfc8aca2 Node WWN 0x20000004cfc8aca2 This Node WWN would then be used like so: echo "GEOM::FOX 20000004cfc8aca2" | dd of=/dev/da2 conv=sync For non-FibreChannel devices you could for example use the serial number of the device. Regardless of what you use, make sure the label is unique. Once the labelling has been performed and assuming the geom_fox module is loaded the kernel will inform you that it has found a new geom_fox device with a message similar to Creating new fox (da2) fox da2.fox lock 0xfffffc0000fdba20 o To check which physical devices match a given geom_fox device: # geom fox list Geom name: da2.fox Providers: 1. Name: da2.fox Mediasize: 73407865344 (68G) Sectorsize: 512 Mode: r0w0e0 Consumers: 1. Name: da2 Mediasize: 73407865856 (68G) Sectorsize: 512 Mode: r0w0e0 2. Name: da6 Mediasize: 73407865856 (68G) Sectorsize: 512 Mode: r0w0e0 o To check the status of the geom_fox components: # geom fox status Name Status Components da2.fox N/A da2 da6 SEE ALSO
GEOM(4), geom(8), gmultipath(8) CAVEATS
The geom_fox driver depends on the underlying hardware drivers to do the right thing in case of a path failure. If for example a hardware driver continues to retry forever, geom_fox is not able to re-initiate the I/O to an alternative physical path. You have to be very sure to provide a unique label for each of the geom_fox devices. Safety belts are not provided. For FibreChannel devices it is suggested to use the Port WWN of the device. The World Wide Name is guaranteed to be worldwide unique per the FibreChannel standard. AUTHORS
The geom_fox driver was written by Poul-Henning Kamp <phk@FreeBSD.org>. This manual page was written by Wilko Bulte <wilko@FreeBSD.org>. BUGS
The geom_fox framework has only seen light testing. There definitely might be dragons here. The name geom_fox is completely obscure. Just remember that any sly fox has multiple exits from its hole. The examples provided are too FibreChannel-centric. BSD
January 2, 2005 BSD
All times are GMT -4. The time now is 06:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy