09-19-2006
substring using AWK
can we do substring fuctionality using AWK
say I have string "sandeep"
can i pick up only portion "nde" from it.
Thanks and Regards
Sandeep Ranade
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi guys, hopefully you can give me a hand with this before my monitor has a nasty accident! :mad:
I have the following line in a script:
awk 'int(substr($1,2,2))>'06' && int(substr($1,2,2))<'08' ' ANYOLDFILE.log
... which when ran against this data file:
... correctly... (3 Replies)
Discussion started by: dlam
3 Replies
2. Shell Programming and Scripting
I am trying to get a substring from a string stored in a variable. I tried sed with a bit help from this forum, but not successful. Here is my problem.
My string is: "REPLYFILE=myfile.txt"
And I need: myfile.txt (everything after the = symbol).
My string is: "myfile.txt.gz.20091120.enc... (5 Replies)
Discussion started by: jamjam10k
5 Replies
3. Shell Programming and Scripting
Hi Team,
How to get the last 3 characters of a String irrespective of their length using awk?
Thanks
Kinny (5 Replies)
Discussion started by: kinny
5 Replies
4. Shell Programming and Scripting
Hi Gurus,I have a seemingly simple problem but struggling with it.It is as follows :
I/p string -
ABCDEFGHIJ20100909.txt
desired o/p -
AB,DEF,20100909,ABCDEFGHIJ20100909.txt
How to achieve it ?Thanks in advance.
Please use code tags, thank you (20 Replies)
Discussion started by: sumoka
20 Replies
5. Shell Programming and Scripting
Hi Gurus,
I am working with a korn shell script to simplify some operations of creation file of spool for a Bulk-Copy. Thi is my code:
In a for cycle:
gzcat ${file} |awk '{ print substr($0,1,5)";"substr($0,108,122)";"substr($0,124,131)";"substr($0,139,152)";"substr($0,154,163)";"}' >>... (6 Replies)
Discussion started by: GERMANICO
6 Replies
6. Shell Programming and Scripting
Hi Experts,
I have a file on which i want to print the line which should match following criterias.
Line should not start with 0 or 9
and
Line should start with 1
and
(
576th character should not be 1 or 2
or
576-580 postion should not be NIPPF or CDIPB
or
576-581 postion should... (2 Replies)
Discussion started by: millan
2 Replies
7. Shell Programming and Scripting
Hi
I have a table like this
I want to know how many times the string in 2nd column appears in the first column as substring.
For example the first string of 2nd column "cgt" occurs 3 times in the 1st column and "acg" one time.
So my desired output is
THank you very much in advance:) (14 Replies)
Discussion started by: polsum
14 Replies
8. UNIX for Advanced & Expert Users
Hi All,
I need some help with an awk command:
What I'm trying to do is append "MYGROUP: " to text with the substring "AT_"
the input file follows this format:
AT_xxxxxx
Name1
Name2
AT_xxxxxx
NameA
NameB
I want the output to be:
MYGROUP: AT_xxxxx
Name1
Name2
MYGROUP:... (2 Replies)
Discussion started by: bikecraft
2 Replies
9. Shell Programming and Scripting
Hi All,
I have a log file in which name and version of applications are coming in the following format
name
It may look like following, based on the name of the application and version:
XYZ OR xyz OR XyZ OR xyz
I want to separate out the name and version and store them into variables.... (4 Replies)
Discussion started by: bhaskar_m
4 Replies
10. Shell Programming and Scripting
Can someone help me to make this code without cutting off words ni the string?
awk '{for(i=1;i<length;i+=100) print substr($0,i,100)}'
Thank you! (4 Replies)
Discussion started by: sanantonio7777
4 Replies
wcsstr(3) Library Functions Manual wcsstr(3)
NAME
wcsstr - Finds a wide-character substring
LIBRARY
Standard C Library (libc)
SYNOPSIS
#include <wchar.h>
wchar_t *wcsstr( const wchar_t *s1, const wchar_t *s2);
STANDARDS
Interfaces documented on this reference page conform to industry standards as follows:
wcsstr(): XSH5.0
Refer to the standards(5) reference page for more information about industry standards and associated tags.
PARAMETERS
Specifies the wide-character string being searched. Specifies the wide-character substring to be located.
DESCRIPTION
The wcsstr() function locates the first occurrence in the wide-character string pointed to by the s1 parameter of the sequence of wide
characters in the wide-character string pointed to by the s2 parameter, excluding the terminating null wide character.
RETURN VALUES
Upon successful completion, the wcsstr() function returns a pointer to the located wide-character substring or a null pointer when the sub-
string is not found. If the s2 parameter points to a wide-character substring having 0 (zero) length, the wcsstr() function returns the
entire wide-character string pointed to by parameter s1.
[Tru64 UNIX] On error, the function returns a null pointer.
RELATED INFORMATION
Functions: strstr(3), wcswcs(3)
Standards: standards(5) delim off
wcsstr(3)