Sponsored Content
Top Forums Shell Programming and Scripting Need help to get the nth field of the variable Post 302542553 by itkamaraj on Thursday 28th of July 2011 03:04:31 AM
Old 07-28-2011
Code:
 
echo "SPLASH/tags" | awk -F"/" '{print NF}'

 

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
CRM_RESOURCE(8) 						  [FIXME: manual]						   CRM_RESOURCE(8)

NAME
crm_resource - interact with the Cluster Resource Manager SYNOPSIS
crm_resource [-?|-V|-S] -L|-Q|-W|-D|-C|-P|-p [options] DESCRIPTION
The crm_resource command performs various resource-related actions on the cluster. It can modify the definition of configured resources, start and stop resources, and delete and migrate resources between nodes. --help, -? Print the help message. --verbose, -V Turn on debug information. Note Increase the level of verbosity by providing additional instances. --quiet, -Q Print only the value on stdout (for use with -W). COMMANDS
--list, -L List all resources. --query-xml, -x Query a resource. Requires: -r --locate, -W Locate a resource. Requires: -r --migrate, -M Migrate a resource from its current location. Use -H to specify a destination. If -H is not specified, the resource is forced to move by creating a rule for the current location and a score of -INFINITY. Note This prevents the resource from running on this node until the constraint is removed with -U. Requires: -r, Optional: -H, -f --un-migrate, -U Remove all constraints created by -M Requires: -r --delete, -D Delete a resource from the CIB. Requires: -r, -t --cleanup, -C Delete a resource from the LRM. Requires: -r. Optional: -H --reprobe, -P Recheck for resources started outside the CRM. Optional: -H --refresh, -R Refresh the CIB from the LRM. Optional: -H --set-parameter string, -p string Set the named parameter for a resource. Requires: -r, -v. Optional: -i, -s --get-parameter string, -g string Get the named parameter for a resource. Requires: -r. Optional: -i, -s --delete-parameter string, -d string Delete the named parameter for a resource. Requires: -r. Optional: -i --get-property string, -G string Get the named property (such as class, type, or is_managed) of a resource. Requires: -r --set-property string, -S string Set the named property (not parameter) for a resource. Requires: -r, -t, -v OPTIONS
--resource string, -r string Specify the resource ID. --resource-type string, -t string Specify the resource type (primitive, clone, group, etc.). --property-value string, -v string Specify the property value. --host-uname string, -H string Specify the hostname. --force-relocation, -f Force the resource to move by creating a rule for the current location and a score of -INFINITY This should be used if the resource's stickiness and constraint scores total more than INFINITY (currently 100,000). Note This prevents the resource from running on this node until the constraint is removed with -U. -s string (Advanced Use Only) Specify the ID of the instance_attributes object to change. -i string (Advanced Use Only) Specify the ID of the nvpair object to change or delete. EXAMPLES
Listing all resources: crm_resource -L Checking where a resource is running (and if it is): crm_resource -W -r my_first_ip If the my_first_ip resource is running, the output of this command reveals the node on which it is running. If it is not running, the output shows this. Start or stop a resource: crm_resource -r my_first_ip -p target_role -v started crm_resource -r my_first_ip -p target_role -v stopped Query the definition of a resource: crm_resource -Q -r my_first_ip Migrate a resource away from its current location: crm_resource -M -r my_first_ip Migrate a resource to a specific location: crm_resource -M -r my_first_ip -H c001n02 Allow a resource to return to its normal location: crm_resource -U -r my_first_ip Note The values of resource_stickiness and default_resource_stickiness may mean that it does not move back. In such cases, you should use -M to move it back before running this command. Delete a resource from the CRM: crm_resource -D -r my_first_ip -t primitive Delete a resource group from the CRM: crm_resource -D -r my_first_group -t group Disable resource management for a resource in the CRM: crm_resource -p is_managed -r my_first_ip -t primitive -v off Enable resource management for a resource in the CRM: crm_resource -p is_managed -r my_first_ip -t primitive -v on Reset a failed resource after having been manually cleaned up: crm_resource -C -H c001n02 -r my_first_ip Recheck all nodes for resources started outside the CRM: crm_resource -P Recheck one node for resources started outside the CRM: crm_resource -P -H c001n02 FILES
/var/lib/heartbeat/crm/cib.xml--the CIB (minus status section) on disk. Editing this file directly is strongly discouraged. SEE ALSO
???, ???, lrmadmin(8), heartbeat(8) AUTHOR
crm_resource was written by Andrew Beekhof. [FIXME: source] 07/05/2010 CRM_RESOURCE(8)
All times are GMT -4. The time now is 09:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy