Sponsored Content
Top Forums Shell Programming and Scripting To cut a string based on last index of identifier Post 302761099 by vivek d r on Friday 25th of January 2013 05:36:42 AM
Old 01-25-2013
To cut a string based on last index of identifier

here below is sample string

Code:
null pointer dereference of 'resourceList' where null is returned from a method/opt/bld/fetch/ds/interzone/notification/LocalLineStatusNotificationListener.java:79
null pointer dereference of 'reList' where null is returned from a method/opt/bld/fetch/dunkindev6jbe4/src/com/ip/interzone/notification/LineStatusListener.java:45

i want to cut based on last index of '/' identifier.

i tried

Code:
 
cat fileName.txt | awk '.java' '{print $1}' | cut -d'/' f5

but that would return only for partial since there are different number of '/' for each line.. so i need something to find last index of '/' and cut it and provide me only java file name
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

merging column from two files based on identifier

Hi, I have two files consisting of two columns. So I want to merge column 2 if column 1 is the same. So heres an example of what I mean. FILE1 driver 444 car 333 hat 222 FILE2 driver 333 car 666 hat 999 So I want to merge the column 2's together so... (4 Replies)
Discussion started by: phil_heath
4 Replies

2. UNIX for Dummies Questions & Answers

string index

I have a line "My name is Deepak" How can i search a string Deepak in the line and find out its index position. Here in this case the result should be 12. (3 Replies)
Discussion started by: dr46014
3 Replies

3. UNIX for Dummies Questions & Answers

how to get index/postion of a string?

Hi, I have a string like the following: /db1/data/GLIDER/SYSTEM.dbf need to find the postion where "SYSTEM.dbf" starts, so I tried: LOCATION=/db1/data/GLIDER/SYSTEM.dbf $ expr index $LOCATION SYSTEM expr: syntax error $ expr index "$LOCATION" SYSTEM expr: syntax error ... (5 Replies)
Discussion started by: seafan
5 Replies

4. Shell Programming and Scripting

error while extracting a line from a file based on identifier

here is the content of input file CREATE TABLE `bla bla bla` ( `allianceSiteId` int(11) DEFAULT NULL, `trunkGroupsId` int(11) DEFAULT NULL, `lastModified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, UNIQUE KEY `allianceSiteId`... (4 Replies)
Discussion started by: vivek d r
4 Replies

5. Emergency UNIX and Linux Support

awk cut column based on string

Using awk I required to cut out column contain word "-Tag" regardles of any order of contents and case INsensitive -Tag:messages -P:/var/log/messages -P:/var/log/maillog -K:Error -K:Warning -K:critical Please Guide ...... --Shirish Shukla ---------- Post updated at 05:58 AM... (15 Replies)
Discussion started by: Shirishlnx
15 Replies

6. Shell Programming and Scripting

build array name based on loop index

Hi, I am new to perl and I have the following query please help here. I have following array variables declaration @pld1 = qw(00 01 02 03 04 05); @pld2 = qw(10 11 12 13 14 15); for(my $k=1;$k<=2;$k++) { //I want here to use @pld1 if $k is 1 // and @pld2 if $k is 2. How to do... (3 Replies)
Discussion started by: janavan
3 Replies

7. UNIX for Dummies Questions & Answers

how to cut based on a string

Hi I have some data where each line will look something like this: Time, name, i.d number, RB: 0.9949; RMQA: 0.0005; RB: 0.9951; RRA: 0.3; RA: 0.995; RA: 0.996; EA: 0.99105 etc. I want to cut out all the RB: and RA:'s with the numbers after. so in the above example i'd be left... (3 Replies)
Discussion started by: gvc
3 Replies

8. Shell Programming and Scripting

Comparing the value of a string index to a variable.

Hi, coding a simple program to compare an entered number to a randomly generated one. The number of digits are restricted so I'm just trying to figure out how to refer to the index value in a string and then compare it to the variable I want. I don't know if bash automatically indexes strings, so... (7 Replies)
Discussion started by: outofcookies
7 Replies

9. Shell Programming and Scripting

Sum column values based in common identifier in 1st column.

Hi, I have a table to be imported for R as matrix or data.frame but I first need to edit it because I've got several lines with the same identifier (1st column), so I want to sum the each column (2nd -nth) of each identifier (1st column) The input is for example, after sorted: K00001 1 1 4 3... (8 Replies)
Discussion started by: sargotrons
8 Replies

10. Shell Programming and Scripting

Files summary using awk based on index key

Hello , I have several files which are looking similar to : file01.txt keyA001 350 X string001 value001 keyA001 450 X string002 value007 keyA001 454 X string002 value004 keyA001 500 X string003 value005 keyA001 255 X string004 value006 keyA001 388 X string005 value008 keyA001 1278 X... (4 Replies)
Discussion started by: alex2005
4 Replies
index(3C)						   Standard C Library Functions 						 index(3C)

NAME
index, rindex - string operations SYNOPSIS
#include <strings.h> char *index(const char *s, int c); char *rindex(const char *s, int c); DESCRIPTION
The index() and rindex() functions operate on null-terminated strings. The index() function returns a pointer to the first occurrence of character c in string s. The rindex() function returns a pointer to the last occurrence of character c in string s. Both index() and rindex() return a null pointer if c does not occur in the string. The null character terminating a string is considered to be part of the string. USAGE
On most modern computer systems, you can not use a null pointer to indicate a null string. A null pointer is an error and results in an abort of the program. If you wish to indicate a null string, you must use a pointer that points to an explicit null string. On some machines and with some implementations of the C programming language, a null pointer, if dereferenced, would yield a null string. Though often used, this practice is not always portable. Programmers using a null pointer to represent an empty string should be aware of this portability issue. Even on machines where dereferencing a null pointer does not cause an abort of the program, it does not necessarily yield a null string. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ SEE ALSO
bstring(3C), malloc(3C), string(3C), attributes(5), standards(5) SunOS 5.10 24 Jul 2002 index(3C)
All times are GMT -4. The time now is 03:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy