Sponsored Content
Top Forums Shell Programming and Scripting Need help to get the nth field of the variable Post 302542574 by zaxxon on Thursday 28th of July 2011 03:48:26 AM
Old 07-28-2011
Moderator's Comments:
Mod Comment Please use code tags, thanks. You got a PM with an explanation already - tell us if it is not clear how to use them. Else you might get infractions for not using code tags.


Yea check out itkamaraj's post and maybe my 2nd post, which should handle all cases in your posted file.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk substitute variable value in nth field

I have a large csv file that looks like this: The 3rd field is a unix time stamp that I want to convert to human readable. I wrote a bash script with this code: IFS=$',' cat $1 | while read ID user DATE text flags read; do echo -e "$ID,$user,$(date -d @$DATE),$text,$flags,$read... (3 Replies)
Discussion started by: stumpyuk
3 Replies

2. Shell Programming and Scripting

How to Print from nth field to mth fields using awk

Hi, Is there any short method to print from a particular field till another filed using awk? Example File: File1 ==== 1|2|acv|vbc|......|100|342 2|3|afg|nhj|.......|100|346 Expected output: File2 ==== acv|vbc|.....|100 afg|nhj|.....|100 (8 Replies)
Discussion started by: machomaddy
8 Replies

3. UNIX for Dummies Questions & Answers

change field separator only from nth field until NF

Hi ! input: 111|222|333|aaa|bbb|ccc 999|888|777|nnn|kkk 444|666|555|eee|ttt|ooo|ppp With awk, I am trying to change the FS "|" to "; " only from the 4th field until the end (the number of fields vary between records). In order to get: 111|222|333|aaa; bbb; ccc 999|888|777|nnn; kkk... (1 Reply)
Discussion started by: beca123456
1 Replies

4. Shell Programming and Scripting

Awk product of nth field

How do I do the product of nth filed just like sum. For sum I know like awk '{ sum += $12 } END {printf "%.2f\n", sum}' works as initial sum = 0. But for product how do initialize the variable to 1? (2 Replies)
Discussion started by: madhavb
2 Replies

5. UNIX for Dummies Questions & Answers

Print Nth to last field

Hey, I'm sure this is answered somewhere but my Googling has turned up nothing. I have a file with data in the following format: <desription of event> at <time and date>The desription of the event is variable length and hence when the list is displayed it is hard to easily see the date (and... (8 Replies)
Discussion started by: RECrerar
8 Replies

6. Shell Programming and Scripting

Nth field should have space and rest commas

Hello I was working on a script where the output of my file is 1234 4567 8973 43214 78965 I need the value in below format of this file.The nth field should have space instead of ,(comma) 1234,4567,8973,43214 78965 I tried the code but not working completely xargs <temp_PP.7250... (3 Replies)
Discussion started by: anuragpgtgerman
3 Replies

7. Shell Programming and Scripting

Replace a value of Nth field of nth row

Using Awk, how can I achieve the following? I have set of record numbers, for which, I have to replace the nth field with some values, say spaces. Eg: Set of Records : 4,9,10,55,89,etc I have to change the 8th field of all the above set of records to spaces (10 spaces). Its a delimited... (1 Reply)
Discussion started by: deepakwins
1 Replies

8. Shell Programming and Scripting

Replace pattern from nth field from a file

$ cat /cygdrive/d/Final2.txt 1,A ,Completed, 07.03_23.01 ,Jun 30 20:00 2,BBB,Pending,, 3,CCCCC,Pending,, 4,DDDDD,Pending,, 5,E,Pending,, 6,FFFF,Pending,, 7,G,Pending,, In the above file 4th field is date which is in MM.DD_HH.MIN format and I need to convert it to as it is there in 5th... (1 Reply)
Discussion started by: Amit Joshi
1 Replies

9. Shell Programming and Scripting

Replace pattern from nth field from a file

I have posted this again as old post is closed and I am not able to reopen. so please consider this new post Input File : 1,A,Completed,06.02_19.36,Jun 30 20:00 2,BBB,Failed,07.04_05.12,Jul 21 19:06 3,CCCCC,New,07.21_03.03,Jul 26 12:57 4,DDDDD,Pending,, I wast output file as: ... (7 Replies)
Discussion started by: Amit Joshi
7 Replies

10. UNIX for Advanced & Expert Users

Help changing date format in the nth field

Hi, I have two (2) things that I want to do. First is to change the date format that is in the nth field from MM/DD/YY to YY/MM/DD. Preferably, I wish I know how to make it a 4-digit year but I don't. Problem is I can only assume it is a 20 century Second is somehow know how to figure out... (1 Reply)
Discussion started by: newbie_01
1 Replies
OCF_HEARTBEAT_ETHMON(7) 					OCF resource agents					   OCF_HEARTBEAT_ETHMON(7)

NAME
ocf_heartbeat_ethmonitor - Monitors network interfaces SYNOPSIS
ethmonitor [start | stop | status | monitor | meta-data | validate-all] DESCRIPTION
Monitor the vitality of a local network interface. You may setup this RA as a clone resource to monitor the network interfaces on different nodes, with the same interface name. This is not related to the IP adress or the network on which a interface is configured. You may use this RA to move resources away from a node, which has a faulty interface or prevent moving resources to such a node. This gives you independend control of the resources, without involving cluster intercommunication. But it requires your nodes to have more than one network interface. The resource configuration requires a monitor operation, because the monitor does the main part of the work. In addition to the resource configuration, you need to configure some location contraints, based on a CIB attribute value. The name of the attribute value is configured in the 'name' option of this RA. Example constraint configuration: location loc_connected_node my_resource_grp rule ="rule_loc_connected_node" -INF: ethmonitor eq 0 The ethmonitor works in 3 different modes to test the interface vitality. 1. call ip to see if the link status is up (if link is down -> error) 2. call ip an watch the RX counter (if packages come around in a certain time -> success) 3. call arping to check wether any of the IPs found in the lokal ARP cache answers an ARP REQUEST (one answer -> success) 4. return error SUPPORTED PARAMETERS
interface The name of the network interface which should be monitored (e.g. eth0). (unique, required, string, no default) name The name of the CIB attribute to set. This is the name to be used in the constraints. Defaults to "ethmonitor-'interface_name'". (unique, optional, string, no default) multiplier Multiplier for the value of the CIB attriobute specified in parameter name. (optional, integer, default 1) repeat_count Specify how often the interface will be monitored, before the status is set to failed. You need to set the timeout of the monitoring operation to at least repeat_count * repeat_interval (optional, integer, default 5) repeat_interval Specify how long to wait in seconds between the repeat_counts. (optional, integer, default 10) pktcnt_timeout Timeout for the RX packet counter. Stop listening for packet counter changes after the given number of seconds. (optional, integer, default 5) arping_count Number of ARP REQUEST packets to send for every IP. Usually one ARP REQUEST (arping) is send (optional, integer, default 1) arping_timeout Time in seconds to wait for ARP REQUESTs (all packets of arping_count). This is to limit the time for arp requests, to be able to send requests to more than one node, without running in the monitor operation timeout. (optional, integer, default 1) arping_cache_entries Maximum number of IPs from ARP cache list to check for ARP REQUEST (arping) answers. Newest entries are tried first. (optional, integer, default 5) SUPPORTED ACTIONS
This resource agent supports the following actions (operations): start Starts the resource. Suggested minimum timeout: 20s. stop Stops the resource. Suggested minimum timeout: 20s. status Performs a status check. Suggested minimum timeout: 20s. Suggested interval: 10s. monitor Performs a detailed status check. Suggested minimum timeout: 20s. Suggested interval: 10s. meta-data Retrieves resource agent metadata (internal use only). Suggested minimum timeout: 5s. validate-all Performs a validation of the resource configuration. Suggested minimum timeout: 20s. EXAMPLE
The following is an example configuration for a ethmonitor resource using the crm(8) shell: primitive p_ethmonitor ocf:heartbeat:ethmonitor params interface=string op monitor depth="0" timeout="20s" interval="10s" SEE ALSO
http://www.linux-ha.org/wiki/ethmonitor_(resource_agent) AUTHOR
Linux-HA contributors (see the resource agent source for information about individual authors) resource-agents UNKNOWN 03/09/2014 OCF_HEARTBEAT_ETHMON(7)
All times are GMT -4. The time now is 06:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy