I have a file with a name and then a number:
Apple 1.1
Apple 1.5
Apple 1.9
Banana 1.3
Banana 2.7
Banana 3.3
I'd like to print out the first string followed by the second number rounded down or truncated:
Apple 1
Apple 1
Apple 1
Banana 1
Banana 2
Banana 3
I was trying: (3 Replies)
I have a script wherein I access each line of the file using a FOR loop and then perform some operations in each line. The problem is each line that gets extracted in FOR loop truncates trailing blank spaces and control characters (^M) that is present at the end of each line. I don't wan this to... (5 Replies)
How do you truncate specific parts of a string.
Example:
1 This is the string
Goal:
This is the string
As you can see I'm trying to simply remove the first two characters of the string the number one and the space between the one and the word "this."
Your help is appreciated.
... (8 Replies)
Hi,
I want to truncate a string variable, returned in the script. In perl I used the below and it worked.
BRNo=BR12345
$BR = substr($BRNo, 2, 7)
How can I do it in sh.
Thanks ! (8 Replies)
Hi All ,
My below script is for chacking vaule and then trucating table :
___________
test4@aceuatcs04:/u01/test4/SOLID/Testscript>cat TRUNCATE-PS_TXN.sh
#--------------------------------------------------------------------
# Created by:Kaushlesh Yadav
# Generated on: 15/07/2010
# Job... (4 Replies)
hi,
I have an data from file where it has
20110904 234516 <<hdd-10#console|0c.57,passed,5,28,READ,0,20822392,8,5,4,0,40,0,-1,0,29909,25000,835,3.3,0,0,0,0,implied,0,0,2011/9/5-2:3:17,2011/9/5-2:3:47,X292_0F15,TAP ,NQ09,J40LTG\r\r\n
I want to remove characters till #console| i.e want... (1 Reply)
From strings stored in variables, I need to isolate and use the first numerical value contained within them. I will need to know how to produce an integer as well as a floating point decimal. It needs to work on any string regardless of what types of characters (if any) are preceding or following... (3 Replies)
Hello:
I have a large file which contains lines like the following:
1/t123ab, &Xx:1:1234:12345:123456@ABCDEFG... at -$100.00%
/t is a tab, spaces are as indicated
the string "&Xx:1:1234:12345:123456$ABCDEFG..." has a slightly variable number of numbers and letters, but it always starts... (9 Replies)
Hi,
I am trying to remove lines once a string is found till another string is found including the start string and end string. I want to basically grab all the lines starting with color (closing bracket). PS: The line after the closing bracket for color could be anything (currently 'more').... (1 Reply)
Dear All
I am having a text file which is having more than 200 lines.
EX:
001010122 12000 BIB 12000 11200 1200003
001010122 2000 AND 12000 11200 1200003
001010122 12000 KVB 12000 11200 1200003
In the above file i want to search for string KVB... (5 Replies)
Discussion started by: suryanarayana
5 Replies
LEARN ABOUT SUNOS
strrspn
strfind(3GEN) String Pattern-Matching Library Functions strfind(3GEN)NAME
strfind, strrspn, strtrns, str - string manipulations
SYNOPSIS
cc [ flag ... ] file ... -lgen [ library ... ]
#include <libgen.h>
int strfind(const char *as1, const char *as2);
char *strrspn(const char *string, const char *tc);
char * strtrns(const char *string, const char *old, const char *new, char *result);
DESCRIPTION
The strfind() function returns the offset of the first occurrence of the second string, as2, if it is a substring of string as1. If the
second string is not a substring of the first string strfind() returns -1.
The strrspn() function trims chartacters from a string. It searches from the end of string for the first character that is not contained in
tc. If such a character is found, strrspn() returns a pointer to the next character; otherwise, it returns a pointer to string.
The strtrns() function transforms string and copies it into result. Any character that appears in old is replaced with the character
in the same position in new. The new result is returned.
USAGE
When compiling multithreaded applications, the _REENTRANT flag must be defined on the compile line. This flag should only be used in mul-
tithreaded applications.
EXAMPLES
Example 1: An example of the strfind() function.
/* find offset to substring "hello" within as1 */
i = strfind(as1, "hello");
/* trim junk from end of string */
s2 = strrspn(s1, "*?#$%");
*s2 = '