Sponsored Content
Top Forums Shell Programming and Scripting Divide the file into several Variable Post 302413285 by Franklin52 on Thursday 15th of April 2010 06:19:17 AM
Old 04-15-2010
Quote:
Originally Posted by amaulana
thanks bro..

devide to 3 variables (but 3 files are also ok), your script tested ini solaris and this is the result:

the file still in 1 file and this is the result:

BTS 0 UNLOCKED ENABLED NONE TRX 0 UNLOCKED ENABLED NONE TRX 1 UNLOCKED ENABLED NONE
BTS 1 UNLOCKED ENABLED NONE TRX 0 UNLOCKED ENABLED NONE TRX 1 UNLOCKED ENABLED NONE
BTS 2 UNLOCKED ENABLED NONE TRX 0 UNLOCKED ENABLED NONE TRX 1 UNLOCKED ENABLED NONE

we can use BTS number as the name of its variable or file, BTS0 for variable number 1, BTS1 for variable number 2 and so on. So the result wanted are:

for variable number 1 (BTS0), contain the text:
BTS 0 UNLOCKED ENABLED NONE
TRX 0 UNLOCKED ENABLED NONE
TRX 1 UNLOCKED ENABLED NONE

for variable number 2 (BTS1), contain the text:
BTS 1 UNLOCKED ENABLED NONE
TRX 0 UNLOCKED ENABLED NONE
TRX 1 UNLOCKED ENABLED NONE

for variable number 3 (BTS2), contain the text:
BTS 2 UNLOCKED ENABLED NONE
TRX 0 UNLOCKED ENABLED NONE
TRX 1 UNLOCKED ENABLED NONE
Try this:
Code:
awk '/BTS/{f=$2}{print > "BTS" f}'  file

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

script needs to divide by 2

i need to divide this count by 2, what variable can i use in my script? 26 hcscprod_cpus_totals /2 = 13 13 hcncprod_cpus_totals /2= 6.5 541 ktazp_cpus_totals /2= 270.5 346 ktazd_cpus_totals /2=173 110 ktazi_cpus_totals /2=55 10 ktazq_cpus_totals /2=5 (2 Replies)
Discussion started by: wereyou
2 Replies

2. Shell Programming and Scripting

how to divide single large log file into multiple files.

Can you please help me with writing script for following purpose. I have to divide single large web access log file into multiple log files based on dates inside the log file. For example: if data is logged in the access file for jan-10-08 , jan-11-08 , Jan-12-08 then make small log file... (1 Reply)
Discussion started by: kamleshm
1 Replies

3. Shell Programming and Scripting

divide a single file with different Weboffercodes into different files with each of o

Here is the format of my file; I do not have the delimiter in the file for the data to be separated. Each line in the file is in the following format. File contains the data of different WebOfferCodes Item Code | Account Number | Card Number | Source code | WebOfferCode 12digits | 10... (4 Replies)
Discussion started by: enigma_83
4 Replies

4. UNIX for Dummies Questions & Answers

divide the file into multiple files based on the city name

Hi, I have a file abc.dat. It contains the fileds of empid, empname, empcity. each city contains 10 records. i want to create the city file and pass the same city records into the file. I don't know the city names. In unix using awk command how can we do? abc.dat: 1 john delhi 2... (2 Replies)
Discussion started by: raghukreddy.ab
2 Replies

5. Shell Programming and Scripting

Divide variable

Hi All, here D Prints the bytes value .plz help to convert the variable D value to MB in new variable $E D=`more $C |awk '{print $6;}'` Thanks in Advance.:) (3 Replies)
Discussion started by: netdbaind
3 Replies

6. Shell Programming and Scripting

Divide two variable

F= `expr $E/$S` output test5.sh: line 45: 1296863.27001857757568359375/21997: No such file or directory can any one help me ,i just want to divide the $E/$S and Print o/p in F. (3 Replies)
Discussion started by: netdbaind
3 Replies

7. Shell Programming and Scripting

Divide number of lines by the size of the same file. And create relational table.

I basically need to do what the title says. I have my text file. I'm still pretty new at this. At the moment I know that: 1. wc -l file.txt To get the number of lines. 2. ls -lh file.txt To get the file size. But I need to divide both numbers. Then I need to save the output in a... (7 Replies)
Discussion started by: PainMaker101
7 Replies

8. UNIX for Dummies Questions & Answers

Divide a numerical data column by a variable

Hello, I have two files, f1 and f2. f1 has 5 columns like so: a b c d 154 e f g h 365 ..... f2 has two columns, the first column contains the name of the above file and second column contains a constant which is to be used for division. e.g. file1 56 I want to divide the 5th... (2 Replies)
Discussion started by: Gussifinknottle
2 Replies

9. UNIX for Dummies Questions & Answers

To divide file

We have large log files, and we need to extract last four hours lines only, Please let us know the command. Thanks, Saurau. (1 Reply)
Discussion started by: saurau
1 Replies

10. Shell Programming and Scripting

Divide the numbers in file

Dear ALL, I have sample file : tx_bytes: 2422, tx_packets: 13, uptime: 16119, tx_bytes: 2342, tx_packets: 14, uptime: 11009, tx_bytes: 252, tx_packets: 12, uptime: 3113, my formula : minutes=$(( uptime/60%60 )) hours=$(( uptime/60/60%24 )) (3 Replies)
Discussion started by: gnulyn
3 Replies
scha_cmds(1HA)						       Sun Cluster Commands						    scha_cmds(1HA)

NAME
scha_cmds - command standard output for scha_cluster_get, scha_control, scha_resource_get, scha_resourcegroup_get, scha_resourcetype_get, scha_resource_setstatus SYNOPSIS
scha_command -O optag... DESCRIPTION
The Sun Cluster scha_cluster_get(1HA), scha_control(1HA), scha_resource_get(1HA), scha_resourcegroup_get(1HA), scha_resourcetype_get(1HA), and scha_resource_setstatus(1HA) commands are command-line implementations of the callback methods for resource types. See rt_call- backs(1HA). Resource types represent services that are controlled by the cluster's Resource Group Manager (RGM) facility. These commands provide a com- mand-line interface to the functionality of the scha_calls(3HA) C functions. The get commands access cluster configuration information. All of these commands have the same general interface. These commands all take an -O optag operand. This operand indicates the information to be accessed. These commands all send the results to the standard output (stdout) as formatted strings. Additional arguments might be needed depending on the command and the value of optag. For information about the format of different optag results, see the "Results Format" section. Note - optag options, for all scha commands, are not case sensitive. You can use any combination of uppercase and lowercase letters when you specify optag options. The scha_control(1HA) command also takes an -O optag option that indicates a control operation, but does not produce output to standard output. The scha_resource_setstatus(1HA) command sets the STATUS and STATUS_MSG properties of a resource that is managed by the RGM. Result Formats The format of strings that are output to the standard output by the commands depends on the type of the result that is indicated by the optag that you include with the -O option. Formats for each type are specified in the following table. Format notation is described in for- mats(5). Result Type Format on Standard Output boolean TRUE or FALSE enum %s , the string name of an enum value. extension %s , the type attribute of the exten- sion property, which is one of the fol- lowing values: STRING, INT, BOOLEAN, ENUM, or STRINGARRAY.Following the type information, the property value is out- put according to the formats for each type as follows: STRING as string, INT as int, BOOLEAN as boolean, ENUM as enum, STRINGARRAY as string_array. int %d status %s %s , the first string is the sta- tus, which is one of the following enum values: DEGRADED, FAULTED, OFFLINE, ONLINE, or UNKNOWN.The second string is the status message. string %s string_array Each element in the array is output in the format %s . An asterisk, indicat- ing all nodes, zones, or resources, can be returned for the GLOBAL_RESOURCES_USED and INSTALLED_NODES properties. unsigned_int %u unsigned_int_array Each element in the array is output in the format %u optag Result Types The following table specifies the valid optag values for different commands as well as the type of the result that is output according to the formats specified in the previous table. optag Values for scha_cluster_get(1HA) Result Type ALL_NODEIDS unsigned_int_array ALL_NODENAMES string_array ALL_NONGLOBAL_ZONES string ALL_NONGLOBAL_ZONES_NODEID string ALL_PRIVATELINK_HOSTNAMES string_array ALL_RESOURCEGROUPS string_array ALL_RESOURCETYPES string_array ALL_ZONES string ALL_ZONES_NODEID string CLUSTERNAME string NODEID_LOCAL unsigned_int NODEID_NODENAME unsigned_int NODENAME_LOCAL string NODENAME_NODEID string NODESTATE_LOCAL enum (UP, DOWN) NODESTATE_NODE enum (UP, DOWN) PRIVATELINK_HOSTNAME_LOCAL string PRIVATELINK_HOSTNAME_NODE string SYSLOG_FACILITY int ZONE_LOCAL string optag Values for scha_control(1HA) -------------------------------------------------------- CHANGE_STATE_OFFLINE CHANGE_STATE_ONLINE CHECK_GIVEOVER CHECK_RESTART GIVEOVER IGNORE_FAILED_START RESOURCE_DISABLE RESOURCE_IS_RESTARTED RESOURCE_RESTART RESTART optag Values for scha_resource_get(1HA) Result Type AFFINITY_TIMEOUT int ALL_EXTENSIONS string_array BOOT_TIMEOUT int CHEAP_PROBE_INTERVAL int CHEAP_PROBE_INTERVAL int EXTENSION extension EXTENSION_NODE extension FAILOVER_MODE enum (NONE, HARD, SOFT, RESTART_ONLY, LOG_ONLY ) FINI_TIMEOUT int GROUP string INIT_TIMEOUT int LOAD_BALANCING_POLICY string LOAD_BALANCING_WEIGHTS string_array LOGICAL_HOSTNAMES_USED string_array MONITORED_SWITCH enum (DISABLED, ENABLED) MONITORED_SWITCH_NODE enum (DISABLED, ENABLED) MONITOR_CHECK_TIMEOUT int MONITOR_START_TIMEOUT int MONITOR_STOP_TIMEOUT int NETWORK_RESOURCES_USED string_array NUM_RESOURCE_RESTARTS int NUM_RESOURCE_RESTARTS_ZONE int NUM_RG_RESTARTS int NUM_RG_RESTARTS int NUM_RG_RESTARTS_ZONE int ON_OFF_SWITCH enum (DISABLED, ENABLED) ON_OFF_SWITCH_NODE enum (DISABLED, ENABLED) PORT_LIST string_array POSTNET_STOP_TIMEOUT int PRENET_START_TIMEOUT int R_DESCRIPTION string RESOURCE_DEPENDENCIES string_array RESOURCE_DEPENDENCIES_OFFLINE_RESTART string_array RESOURCE_DEPENDENCIES_RESTART string_array RESOURCE_DEPENDENCIES_WEAK string_array RESOURCE_PROJECT_NAME string RESOURCE_STATE enum (ONLINE, OFFLINE, START_FAILED, STOP_FAILED, MONITOR_FAILED, ONLINE_NOT_MONITORED, STARTING, STOPPING) RESOURCE_STATE_NODE enum (see RESOURCE_STATE for values) RETRY_COUNT int RETRY_INTERVAL int SCALABLE boolean START_TIMEOUT int STATUS status STATUS_NODE status STOP_TIMEOUT int THOROUGH_PROBE_INTERVAL int TYPE string TYPE_VERSION string UDP_AFFINITY boolean UPDATE_TIMEOUT int VALIDATE_TIMEOUT int WEAK_AFFINITY boolean optag Values for Result Type scha_resource_get(1HA) and scha_resource- type_get(1HA) API_VERSION int BOOT string FAILOVER boolean FINI string GLOBAL_ZONE boolean INIT string INIT_NODES enum (RG_PRIMARIES, RT_INSTALLED_NODES ) INSTALLED_NODES string_array. An asterisk (*) is returned to indicate all nodes. IS_LOGICAL_HOSTNAME boolean IS_SHARED_ADDRESS boolean MONITOR_CHECK string MONITOR_START string MONITOR_STOP string PER_NODE boolean PKGLIST string_array POSTNET_STOP string PRENET_START string PROXY boolean RT_BASEDIR string RT_DESCRIPTION string RT_SYSTEM boolean RT_VERSION string SINGLE_INSTANCE boolean START string STOP string UPDATE string VALIDATE string optag Values for Result Type scha_resourcegroup_get(1HA) AUTO_START_ON_NEW_CLUSTER boolean DESIRED_PRIMARIES int FAILBACK boolean GLOBAL_RESOURCES_USED string_array (an asterisk (*) is returned to indicate all resources) IMPLICIT_NETWORK_DEPENDENCIES boolean MAXIMUM_PRIMARIES int NODELIST string_array PATHPREFIX string PINGPONG_INTERVAL int RESOURCE_LIST string_array RG_AFFINITIES string_array RG_DEPENDENCIES string_array RG_DESCRIPTION string RG_IS_FROZEN boolean RG_MODE enum (FAILOVER, SCALABLE) RG_PROJECT_NAME string RG_SLM_CPU decimal RG_SLM_CPU_MIN decimal RG_SLM_PSET_TYPE enum (DEFAULT, DEDI- CATED_STRONG, DEDICATED_WEAK) RG_SLM_TYPE enum (AUTOMATED, MANUAL) RG_STATE enum (UNMANAGED, ONLINE, OFF- LINE, PENDING_ONLINE, PEND- ING_OFFLINE, ERROR_STOP_FAILED, ONLINE_FAULTED, PEND- ING_ONLINE_BLOCKED) RG_STATE_NODE enum (see RG_STATE for values) RG_SYSTEM boolean SUSPEND_AUTOMATIC_RECOVERY boolean EXIT STATUS
One set of exit status codes is used for all scha commands. The exit status codes are the numeric values of the scha_err_t return codes of the corresponding C functions as described in scha_calls(3HA). ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWscdev | +-----------------------------+-----------------------------+ |Interface Stability |Stable | +-----------------------------+-----------------------------+ SEE ALSO
awk(1), rt_callbacks(1HA), scha_cluster_get(1HA), scha_control(1HA), scha_resource_get(1HA), scha_resourcegroup_get(1HA), scha_resource- type_get(1HA), scha_resource_setstatus(1HA), scha_calls(3HA), attributes(5), formats(5), r_properties(5), rg_properties(5), rt_proper- ties(5) Sun Cluster 3.2 13 Jul 2006 scha_cmds(1HA)
All times are GMT -4. The time now is 09:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy