Sponsored Content
Top Forums Shell Programming and Scripting How to Split File to 2 depending on condition? Post 302857185 by OTNA on Wednesday 25th of September 2013 03:07:53 PM
Old 09-25-2013
How to Split File to 2 depending on condition?

Hi ,


cat myfile.txt

Code:
! 3100.2.0.5 ! 3100.2.22.4 ! 3100.2.30.33 ! 3100.2.4.1 !
! 3100.2.0.5 ! 3100.2.22.4 ! 3100.2.22.11 ! 3100.2.4.1 !
! 3100.2.0.5 ! 3100.2.2.50 ! 3100.2.22.11 ! 3100.2.4.1 !
! 3100.2.0.5 ! 3100.2.22.4 ! 3100.2.30.33 ! 3100.2.4.1 !
! 3100.2.0.5 ! 3100.2.22.4 ! 3100.2.20.11 ! 
! 3100.2.0.5 ! 3100.2.11.1 ! 3100.2.60.07 ! 3100.2.4.1 !

i need to split this file to 2 file , the first contains all the lines with occurrence the 3100.2.22.4 and absecne of 3100.2.22.11



and the second file contains all other lines , the result should be like below ,

myfile1
Code:
! 3100.2.0.5 ! 3100.2.22.4 ! 3100.2.30.33 ! 3100.2.4.1 !
! 3100.2.0.5 ! 3100.2.22.4 ! 3100.2.30.33 ! 3100.2.4.1 !
! 3100.2.0.5 ! 3100.2.22.4 ! 3100.2.20.11 !

myfile2
Code:
! 3100.2.0.5 ! 3100.2.22.4 ! 3100.2.22.11 ! 3100.2.4.1 !
! 3100.2.0.5 ! 3100.2.2.50 ! 3100.2.22.11 ! 3100.2.4.1 !
! 3100.2.0.5 ! 3100.2.11.1 ! 3100.2.60.07 ! 3100.2.4.1 !

can you help me with this please

Last edited by OTNA; 09-25-2013 at 05:19 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk script to split a file based on the condition

I have the file with the records like 4234234 US phone 3244234 US cup 2342342 CA phone 8947234 US phone 2389472 CA cup 2348972 US maps 3894234 CA phone I want the records with (US,phone) as record to be in one file, (Us, cup) in another file and (CA,cup) to be in another I mean all... (12 Replies)
Discussion started by: superprogrammer
12 Replies

2. Shell Programming and Scripting

split file depending on content

Hi, I have a file which contains records of data. I need to split the file into multiple files depending upon the value of last field. How do i read the last field of each record in the file??? Regards, Chaitrali (4 Replies)
Discussion started by: Chaitrali
4 Replies

3. Shell Programming and Scripting

How to split the String based on condition?

hi , I have a String str="/opt/ibm/lotus/ibw/latest" or ="/opt/lotus/ibw/latest" this value is dynamic..I want to split this string into 2 strings 1. /opt/ibm/lotus(/opt/lotus) this string must ends with "lotus" 2./ibw/latest can any body help me on this? Regards, sankar (2 Replies)
Discussion started by: sankar reddy
2 Replies

4. Shell Programming and Scripting

Split file into multiple files depending upon first 4 digits

Hi All, I have a file like below: 1016D"ddd","343","1299" 1016D"ddd","3564","1299" 1016D"ddd","3297","1393" 1016D"ddd","32989","1527" 1016D"ddd","346498","1652" 2312D"ddd","3269","1652" 2312D"ddd","328","1652" 2312D"ddd","2224","2100" 3444D"ddd","252","2100" 3444D"ddd","2619","2100"... (4 Replies)
Discussion started by: deepakgang
4 Replies

5. Shell Programming and Scripting

split file with condition

$ cat file H1:12:90 k:12:b n:22:i k:54:b k:42:b s:48:s a:41:b t:18:n c:77:a I am trying to split above file based on $2 such that if $2 is rounded to nearest 10's multiple (e.g. 10,20,30 etc), each sub file should contain 3 multiples and so on (also I want to keep header i.e. NR==1, in... (6 Replies)
Discussion started by: uwork72
6 Replies

6. Shell Programming and Scripting

How to reject row from one file to another depending upon some condition

Hi I have a input file say abc.dat which contains data as below name~address~email~ID john~newyork~john@gmail.com~1500D steve~sydney~steve@abc.com~3451E Now if length of name is > 50 or ID is null then the row should rejected to another file say reject.dat along with reason for rejection... (2 Replies)
Discussion started by: saurav2602
2 Replies

7. Shell Programming and Scripting

How to split a data file into separate files with the file names depending upon a column's value?

Hi, I have a data file xyz.dat similar to the one given below, 2345|98|809||x|969|0 2345|98|809||y|0|537 2345|97|809||x|544|0 2345|97|809||y|0|651 9685|98|809||x|321|0 9685|98|809||y|0|357 9685|98|709||x|687|0 9685|98|709||y|0|234 2315|98|809||x|564|0 2315|98|809||y|0|537... (2 Replies)
Discussion started by: nithins007
2 Replies

8. Shell Programming and Scripting

Split file depending on Column Value

Hi , my file look likes below , cat file.csv 12/09/2014,50,5,0,300 12/09/2014, ,5,0,300 12/09/2014,50,,,300 i need to split file , the first one contains values (2nd column is 50 , 3rd and fourth column is null ) the second file contains all others firstfile ... (2 Replies)
Discussion started by: ubaisalih
2 Replies

9. Shell Programming and Scripting

Split a non delimited file into columns depending on user input

I would like some advice on some code. I want to write a small script that will take an input file of this format 111222233334444555666661112222AAAA 2222333445556612323244455445454545 2334556345643534505435345353453453 (and so on) It will be called as : script inputfile X (where X is... (5 Replies)
Discussion started by: onlyforbopi
5 Replies

10. UNIX for Advanced & Expert Users

How to split a large file with the first 100 lines of each condition?

I have a huge file with the following input: Case1 Specific_Info Specific_Info Case1 Specific_Info Specific_Info Case3 Specific_Info Specific_Info Case4 Specific_Info Specific_Info Case1 Specific_Info Specific_Info Case2 Specific_Info Specific_Info Case2 Specific_Info Specific_Info... (2 Replies)
Discussion started by: laurigo
2 Replies
Xws(8X) 																   Xws(8X)

Name
       Xws - X server for RISC machines

Syntax
       Xws [ options ]

Description
       The command starts the X server.  The command supports the following hardware configurations:

	  DECstation/DECsystem 3100 Single Screen Color Workstations
	  DECstation/DECsystem 3100 Single Screen Monochrome Workstations
	  DECstation/DECsystem 5000 Single Screen Color Workstations
	  DECstation/DECsystem 5000 Single Screen Monochrome Workstations
	  DECstation/DECsystem 5000 Multiscreen Color Workstations
	  DECstation/DECsystem 5000 Multiscreen Monochrome Workstations

       The  command  that executes the server is specified together with its command line options in the file and, therefore, is automatically run
       when your system is started in multiuser mode.  Optionally, you can create an file containing device-dependent command line options  (sepa-
       rated by spaces) and use it to start the server.  Command line options specified in the file override those specified in the file.

       Start the server in bug compatibility mode (with the bc option) to remain bug-for-bug compatible with previous releases of the server.

Options
       The  following  options	are  device  independent.  These options are available on all workstation hardware platforms running X11 Release 4
       servers.

       -a num		   Sets the mouse acceleration value to the specified number of pixels.  The default is 4.

       -auth string	   Selects a file containing authorization records.  Hosts listed in the file are allowed to access to the  server's  dis-
			   play.  By default, no authorization file is used.

       bc		   Enables bug compatibility with previous releases.

       -bs		   Disables Backing Store. Backing Store is disabled if you specify the -bs option on the command line.

       -c		   Turns off key clicking.

       c num		   Sets the key click volume to the specified number (0-100).  The default is 20.

       -co string	   Selects a color database.  The default is

       -f num		   Sets the bell volume to the specified number (0-100).  The default is 50.

       -fc string	   Sets the default cursor font.  The default is

       -fd num		   Sets the font size in dots per inch.  Acceptable values are 75 and 100.

       -fn string	   Sets the default text font.	The default is

       -fp string	   Sets the default font directory path.  The default font directory paths are:

       +fp path[,path...]  Prepends the specified font paths to the default path.

       fp+ path[,path...]  Appends the specified font paths to the default path.

       -help		   Displays the command usage message.

       -I		   Directs the server to ignore all remaining command line arguments.

       -ld num		   Limits data space to num Kbytes.

       -ls num		   Limits stack space to num Kbytes.

       -logo		   Enables the X logo screen saver.

       logo		   Disables the X logo screen saver.

       -p seconds	   Determines how long to wait before changing the background pattern of the screen saver.  The default is 10 seconds.

       -r		   Turns off automatic repetition of keyboard key characters.

       r		   Turns on automatic repetition of keyboard key characters.  The default is on.

       -s seconds	   Sets the screen-saver timeout value to the specified number of seconds.  The default is 10.

       -su		   Disables Save-Unders.

       -t num		   Sets  the mouse threshold in pixels.  The mouse will accelerate only if the threshold is exceeded.  The default thresh-
			   old is 4.

       -to seconds	   Specifies the number of seconds for the server to wait before declaring a session connection timed out.

       ttyxx		   Specifies the terminal on which the server is to start.  The Wttyxx is a valid command line option, but it  is  ignored
			   by the WXws server.

       v		   Specifies that a blank screen is used for the screen saver.	This is the default screen saver.

       -v		   Specifies that a pattern (noblank) screen is used for the screen saver.

       -wm		   Enables the use of Backing Store with WhenMapped calls.

       -x string	   Loads the file string containing an X extension.

       :num		   On a multihead system, specifies the head on which the server is run (0 or 1).  The default is 0.

       -broadcast	   Enables X Display Manager Control Protocol (XDMCP) and sends broadcast query packets over the network.

       -displayID display-id
			   For XDMCP, identifies manufacturer's display ID for display

       -indirect hostname  Enables XDMCP and sends indirect query packets to the specified host.

       -once		   Terminates the server after one session.

       -port num	   Specifies the UDP port number that will receive messages.

       -query hostname	   Enables XDMCP and sends query packets to the specified host.

       -XDMCP_class display-class
			   Specifies an additional display qualifier used in resource management by XDMCP.

       The  following  are  device-dependent,  vendor-specific options.  When the server is run on multiscreen capable platforms, selected device-
       dependent options take an optional screen-specification argument.  Omitting the screen-specification argument defines the parameter for all
       available screens.

       -btn num 	   Specifies  the  number of buttons on the pointer device.  The default is three for a mouse device and four for a tablet
			   device.

       -bp[screen]  color  Sets the color of black pixels for the screen.  The color argument can be a named color from the database or  a  number
			   sign (#) followed by a hexidecimal number.

       -class[screen]  visual class
			   Sets the visual class for the root window of the screen.  Possible values are and

       -dpi[screen]  num   Sets the dots per inch for the x and y coordinates.

       -dpix[screen]  num  Sets the dots per inch for the x coordinates.

       -dpiy[screen]  num  Sets the dots per inch for the y coordinates.

       -edge_bottomscr1 scr2
			   Attaches the bottom edge of the screen specified by scr1 to the screen specified by scr2.

       -edge_leftscr1 scr2 Attaches the left edge of the screen specified by scr1 to the screen specified by scr2.

       -edge_rightscr1 scr2
			   Attaches the right edge of the screen specified by scr1 to the screen specified by scr2.

       -edge_topscr1 scr2  Attaches the top edge of the screen specified by scr1 to the screen specified by scr2.

       -wp[screen]  color  Sets the color of white pixels for the screen.  The syntax for color is the same as for the argument to the -bp option.

       -tb n		   Opens  for  graphics  tablet  communications.  The two free serial ports on the DECstation correspond to and A graphics
			   tablet must be connected through one of these two ports.

       -pcm n		   Opens for Protocol Control Module (PCM) communications.  The two free serial ports on the DECstation correspond to  and
			   Dial boxes and button boxes must be connected through these two ports.

Restrictions
       If  options  not  listed in this reference page are used, the server may fail. Using invalid options for the X server in the file may cause
       the workstation to behave as if the X server is hung.

       Multiscreen configurations can contain either two- or three-color frame buffer display devices or monochrome frame buffer display devices.

       Color and monochrome frame buffer display devices cannot be installed in the same workstation.  Only homogeneous installations are allowed.

       To connect two screens, two command line options must be issued.  Attaching two screens using only one argument produces a  one-way  mouse-
       travel path.  You can create a wrap-around mouse path by attaching noncontiguous screen edges.  The arguments are disabled on single screen
       systems.

       Nonsensical screen connections are not allowed; the top edge of a particular screen must be connected  with  the  bottom  edge  of  another
       screen,	and  the right edge of a particular screen must be connected with the left edge of another screen.  Left and right edges cannot be
       connected to top or bottom edges.

Examples
       The following example specifies that screen has a resolution of 100x100 dots per inch and screen has a resolution of 75x70 dots per inch:
       Xws -dpi0 100 -dpix1 75 -dpiy1 70

       If no screen is specified, the value specified is used for all screens.	If the screen resolution  is  not  specified  using  command  line
       options, a default value based on pixel dimensions and screen size is calculated for each screen.

       The  following  example	specifies  that  black pixels on screen have the hexadecimal value 3a009e005c0 prefixed with a number sign (#) and
       white pixels on screen are color "wheat" from the X rgb color database.
       Xws -bp1 #3a009e005c0 -wp1 wheat
       For monochrome display devices, values of 0 and 1 are the only valid pixel colors.

       To specify the default visual class of a root window on a particular screen, append the screen number (0, 1, or	2)  to	the  command  line
       option.	Possible visual classes are: StaticGray, StaticColor, PseudoColor, GrayScale, and TrueColor.  The following example specifies that
       the screen root window is a TrueColor visual, and the screen root window is a PseudoColor visual.
       Xws -class0 TrueColor -class1 PseudoColor

       The following example attaches screen above screen and screen to the right of screen (an L-shaped configuration):
       Xws -edge_top0 1 -edge_bottom1 0 -edge_right0 2 -edge_left2 0

       The following example is identical to the default state (a horizontal line) with the addition of a wraparound from screen to screen
       Xws -edge_left0 2 -edge_right0 1 -edge_left1 0 -edge_right1 2 
       -edge_left2 1 -edge_right2 0

Files
See Also
       X(1X)
       X Window System: The Complete Reference to Xlib, X Protocol, ICCCM, XLFD, by Robert W. Scheifler and James Gettys, Second Edition,  Digital
       Press, 1990
       OSF/MOTIF Programmer's Guide and OSF/MOTIF Reference Guide, Open Software Foundation, Prentice-Hall, 1990

								       RISC								   Xws(8X)
All times are GMT -4. The time now is 03:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy