Sponsored Content
Full Discussion: Read file based on condition
Top Forums Shell Programming and Scripting Read file based on condition Post 302105273 by sbasetty on Wednesday 31st of January 2007 11:00:26 PM
Old 02-01-2007
Read file based on condition

Hi Friends,

Can any one help with this:
I have a huge file with the format as
A SAM 4637
B DEPT1 4758 MILAN
A SMITH 46585
B DEPT2 5385 HARRYIS
B SAMUL 63547 GEORGE
B DANIEL 899 BOISE
A FRES 736 74638


I have to read this file and write only the records that starts with "B" only

output should be:
B DEPT1 4758 MILAN
B DEPT2 5385 HARRYIS
B SAMUL 63547 GEORGE
B DANIEL 899 BOISE



Thanks in advance

S Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Splitting a file based on some condition and naming them

I have a file given below. I want to split the file where ever I came across ***(instead you can put ### symbols in the file) . Also I need to name the file by extracting the report name from the first line which is in bold(eg:RPT507A) concatinated with DD(day on which the file runs). Can someone... (1 Reply)
Discussion started by: srivsn
1 Replies

2. Shell Programming and Scripting

Moving file to directory based on condition.

Can any one help me to correct following script. I have 2 directories DropZone and ProcessZone. File pattern is *VEHDESCSUM*. Finding the 'no of files' in DropZone directory using ls *VEHDESCSUM* |wc -l If DropZone has more than one file or 0 files then exit 1 If DropZone has one file then... (2 Replies)
Discussion started by: ramanagh
2 Replies

3. Shell Programming and Scripting

Spliting file based on condition

Hi, I have a comma separated file with millions of records in it. I have a requirement to split the file based on the value in a one of the columns. Suppose i have a text file with columns like C1, C2,C3,C4 Column C4 can hold the values either 01 or 02 03 or 04. I nned to extract... (2 Replies)
Discussion started by: Raamc
2 Replies

4. Shell Programming and Scripting

Update a field in a file based on condition

Hi i am new to scripting. i have a file file.dat with content as : CONTENT_STORAGE PERCENTAGE FLAG: /storage_01 64% 0 /storage_02 17% 1 I need to update the value of FLAG for a particular CONTENT_STORAGE value I have written the following code #!/bin/sh threshold=20... (1 Reply)
Discussion started by: kichu
1 Replies

5. Shell Programming and Scripting

Move input file based on condition

Hello, I have File1 in a directory A, a File2 in a directory B. If the File2 is not empty Then I have to move File1 from directory A to a directory archive Else no action. Is it possible to do this from one command line? Thank you in advance for your answers. Madi (2 Replies)
Discussion started by: AngelMady
2 Replies

6. Shell Programming and Scripting

How can I change file value based on condition

Hi, Gurus, I got a problem to resolve following issue: I have one file file1as following: start_dt=2010-01-01 12:00:02 start_dt=2011-01-01 09:00:02 start_dt=2009-01-01 11:00:02I have another file file2 as following: title1, 2010-01-03 10:00:02 title2, 2011-01-04 11:00:02 title3,... (5 Replies)
Discussion started by: ken002
5 Replies

7. Shell Programming and Scripting

Read 2 files alternatively based on condition.

Experts, What would be the code in ksh/perl to read 2 files alternatively, based on the following condition. while reading file 1 we check if a blank line is encountered, if yes, then we read file 2 unless a blank line is encountered in file 2 if we have a blank line in file 2 we come back... (3 Replies)
Discussion started by: suraj.sheikh
3 Replies

8. Shell Programming and Scripting

Adding data from a file based on some condition

I collect data in a file in below format(Month Day Year Size) in RedHat Linux. Now i want to calculate the data size date wise. As i code shell script after long time, i forgot the features and syntax. Can anyone help me regard this please. Feb 8 2014 15 Feb 10 2014 32 Feb 10 2014 32 Feb 12... (2 Replies)
Discussion started by: makauser
2 Replies

9. Shell Programming and Scripting

Delete lines from file based on condition

I want to keep last 2 days data from a file and want to delete others data from the file. Please help me. Sample Input # cat messages-2 Apr 15 11:25:03 test1 kernel: imklog 4.6.2, log source = /proc/kmsg started. Apr 15 11:25:03 test1 rsyslogd: (re)start Apr 16 19:42:03 test1 kernel:... (2 Replies)
Discussion started by: makauser
2 Replies

10. Shell Programming and Scripting

Join fields in a same file based on condition

I have an input file like this... All iI want to do is If the lines are identical except for the last field i want to merge them into single line input_file I feel something is nothing I feel something is everything apple mango banana apple mango grapes I want to get output like this:... (3 Replies)
Discussion started by: raj_k
3 Replies
sam(1M) 																   sam(1M)

NAME
sam - HP System Administration Manager (HP SAM) SYNOPSIS
[ login | ] DESCRIPTION
The command launches the HP System Management Homepage (HP SMH) program for performing system administration on the HP-UX operating system. HP SMH is an enhanced web-based program of HP System Administration Manager (HP SAM) in the HP-UX 11i V3 release. For more information, see smh(1M). If the environment variable is set, the Web-based HP SMH is displayed. If the environment variable is not set, the terminal user interface of HP SMH is displayed. Deprecation Notice The command is deprecated in HP-UX 11i V3 release. HP recommends you use the command. Options recognizes the following options. Execute SAM with the privileges associated with the specified login. When used in conjunction with the Restricted SMH Builder is invoked and initialized with the privileges associated with the specified login. You must be a superuser to use this option. See below for more information. Invokes Restricted SMH. This enables the system administrator to assign limited privileged user access to SMH functionality. You must be a privi- leged user to use this option. See the section below for more information. Restricted SMH Generally, SMH requires privileged user rights to execute successfully. However, through the use of Restricted SMH, SMH can be configured to allow subsets of its functionality to certain non-privileged users or groups of users. System administrators access Restricted SMH by invoking SMH with the option (see above). In Restricted SMH, system administrators may assign subsets of SAM functionality on a per-user or per-group basis. When Restricted SMH is used, non-privileged users are promoted to privileged users when necessary to enable them to execute successfully. By default, Restricted SMH executes all applications as privileged user. However, certain applications, like software distributor have their own security mechanism and do not follow the Restricted SMH security model. In such cases, the application launched through Restricted SMH will be executed with the login ID of the user who invokes it. A non-privileged user who has been given Restricted SMH privileges simply executes and sees only those areas the user is privileged to access. All the SMH functional areas require the user to be promoted to be a privileged user in order to execute successfully. SMH does this auto- matically as needed. SMH provides a default set of SMH functional areas that the system administrator can assign to other users. Restricted SMH applies only to terminal user interfaces. Restricted SMH does not apply to Web-based GUI (HP SMH) since HP SMH has its own roles. For more information, refer to the HP SMH documentation available at and the HP SMH product online help system. SAM Functional Areas SAM has been replaced by SMH. For more information on the various functional areas, see smh(1M). SAM Logging All actions taken by SAM are logged into the SAM log file at The log entries in this file can be viewed using the SAM utility command (see samlog_viewer(1)). can filter the log file by user name, by time of log entry creation, and by level of detail. Functionality Obsolescence and Changes The following functional areas of the previous SAM interface have been removed, changed, or are planned to be obsolete in a future release of HP-UX. Alternate procedures are listed as appropriate. o Trusted systems is planned for obsolescence post HP-UX 11i V3 release. o Backup and Recovery. Use the and commands from the HP-UX system prompt. You can also use backup tools, such as pax(1), from the HP-UX command prompt. o Tape Drives. Add or remove device entries by editing the file or use and commands from the HP-UX command prompt. o Terminals and Modems. Use and commands from the HP-UX command prompt. o Uninterruptable Power Supplies. o Performance Management. Monitor the performance of HP-UX using the commands and o Process Management. To manage processes for such functions as stopping, continuing, changing priority, use and o Routine Tasks. Tasks such as shutting down the system and removing files that are large, unowned, or core files are handled by and o Run SAM on Remote Systems. Executing or configuring SAM on remote systems is no longer needed, because all systems are managed through HP Systems Insight Manager (HP SIM). For more information on HP SIM, see o Custom applications cannot be added using SAM. Any custom application that needs to be added in SAM must provide its own registration files. The registration file has a specific format. You can view a sample registration file from WARNINGS
cannot be run in the background even if the environment variable is set from HP-UX 11i V3 release. The Disks and File Systems area of SAM does not display or configure all the types of devices when the legacy mode of mass storage stack is disabled. AUTHOR
was developed by HP. SEE ALSO
samlog_viewer(1), evweb(1M), fsweb(1M), hpsmh(1M), kcweb(1M), ncweb(1M), parmgr(1M), pdweb(1M), secweb(1M), smh(1M), smhstartconfig(1M), ugweb(1M), intro(7). at TO BE OBSOLETED sam(1M)
All times are GMT -4. The time now is 09:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy