Problem is when the line also has irrelevant numbers at the end of the line, it will give a hit to the grep.
You have tested this? As I said, I had not. Taking another look I can see that it could match something like:
To stop this you would need to add something to the end of the pattern to match white space, but this would not match the end of the line. You could add a match for white space to the end of the pattern but then it won't match the end of the line. You could have two versions of my pattern: one with white space a the end and the other with the end of line anchor ($) at the end.
Dear friends
I am new to linux and was trying to split some files userwise in our linux server.
I have a data file of 156 continuous columns named ecscr final.
I want the script to redirect all the lines containing a pattern of 7 digits to separate files. I was using grep to do that,... (2 Replies)
Hi,
I have a log file which contains lines like below:
2010-07-19 07:13:19,021 ERROR system ...(text)
2010-07-19 07:22:03,427 ERROR system ...(text)
class com... (text)
2010-07-19 07:23:19,026 ERROR system ...(text)
class com... (text)
each line is a separate line... I am given the a... (14 Replies)
Hi All,
I have the below file data.txt.Using awk i want to grep all the zone data.Form the below command i can extact data upto of zone i give but i want it should print until next pattern.
awk '/^Total Collection /{c=5;next}c-->0' zin45srs08.tools_utilization
instead of c=5 is it possible... (5 Replies)
Hi All,
I am trying to find numbers with balance greater than 1 and less than equal 2 from the below file using awk
Input file
num ,bal
100199,1.708
100225,0
100226,0
100228,0.771166
100232,2
output file
100199,1.708
100232,2
I am using the following command for this... (2 Replies)
Hello Guyz
I have been following this forum for a while and the solutions provided are super useful. I currently have a scenario where i need to search for a pattern and start searching by keeping the first pattern as a baseline
ABC
DEF
LMN
EFG
HIJ
LMN
OPQ
In the above text i need to... (8 Replies)
Hi,
I have a file with multiple lines(fixed width dat file). I want to search for '02' in the positions 45-46 and if available, in that lines, I need to replace value in position 359 with blank. As I am new to unix, I am not able to figure out how to do this. Can you please help me to achieve... (9 Replies)
Discussion started by: Pradhikshan
9 Replies
7. Post Here to Contact Site Administrators and Moderators
In file, we have millions of records each of 1000 in length. And at specific position say 800 there is a space, we need to replace it with Character X if the ID in that row starts with 123.
So far i have used the below which is replacing space at that position to X but its not checking for... (3 Replies)
Input data as below (filetest.txt):
1|22 JAN Minimum Bal 20.00 | SAT
2|09 FEB Extract bal 168.00BR | REM
3|MIN BAL | LEX
Output should be:
( If there is Date & Month in 2nd field of Input file, It should be seperated else blank. If There is Decimal OR Decimal & Currency in last of the 2nd... (7 Replies)
I have this fileA
TEST FILE ABC
this file contains ABC;
TEST FILE DGHT this file contains DGHT;
TEST FILE 123
this file contains ABC,
this file contains DEF,
this file contains XYZ,
this file contains KLM
;
I want to have a fileZ that has only (begin search pattern for will be... (2 Replies)
Hello,
We have wrote shell script for multiple file name search pattern.
file format: <numner>_<20180809>.txt
starting with single number and ending with 8 digits number
Command:
awk -v string="12_1234" -v serch="^+_+$" "BEGIN{ if (string ~/serch$/) print string }"
If sting matches... (4 Replies)
Discussion started by: koti_rama
4 Replies
LEARN ABOUT DEBIAN
ns_strnstr
Ns_String(3aolserver) AOLserver Library Procedures Ns_String(3aolserver)__________________________________________________________________________________________________________________________________________________NAME
Ns_Match, Ns_NextWord, Ns_StrCaseFind, Ns_StrCopy, Ns_StrDup, Ns_StrNStr, Ns_StrToLower, Ns_StrToUpper, Ns_StrTrim, Ns_StrTrimLeft, Ns_Str-
TrimRight, Ns_StringPrint, ns_strcopy, ns_strdup - library procedures
SYNOPSIS
#include "ns.h"
char *
Ns_Match(char *a, char *b)
char *
Ns_NextWord(char *line)
char *
Ns_StrCaseFind(char *s1, char *s2)
char *
Ns_StrCopy(char *str)
ns_strcopy(char *str)
char *
Ns_StrDup(char *str)
ns_strdup(char *str)
char *
Ns_StrNStr(char *pattern, char *expression)
char *
Ns_StrToLower(char *string)
char *
Ns_StrToUpper(char *string)
char *
Ns_StrTrim(char *string)
char *
Ns_StrTrimLeft(char *string)
char *
Ns_StrTrimRight(char *string)
void
Ns_StringPrint(char *string)
_________________________________________________________________DESCRIPTION
Ns_Match(a, b)
Compare the beginnings of two strings, case insensitively. The comparison stops when the end of the shorter string is reached.
Return NULL if no match, b if match.
Ns_NextWord(line)
Return a pointer to first character of the next word in a string; words are separated by white space. The returned pointer points
into the original string. For example, Ns_NextWord("abc def") returns a pointer to the 'd' in that string.
Ns_StrCaseFind(s1, s2)
Locate the first occurrence of substring s2 within string s1 in a case-insensitive manner. The terminating ' ' characters are not
compared. Returns a pointer that points into s1. Uses strstr(3) to do its work.
Ns_StrCopy(str)
ns_strcopy(str)
Copy a string or NULL value using Ns_Malloc. The Ns_StrCopy function is identical to the Ns_StrDup function but allows for the
string parameter to be NULL, in which case Ns_StrCopy does nothing and returns NULL.
Ns_StrDup(str)
ns_strdup(str)
Copy a string using Ns_Malloc. The Ns_StrDup function calls Ns_Malloc to allocate enough memory to make a copy of the given string.
Ns_StrNStr(pattern, expression)
Search through pattern for expression, case insensitively. Return a pointer that points to where the match begins within pattern, or
NULL if expression is not contained in pattern.
Ns_StrToLower(string)
Convert string to lowercase. Returns pointer to original string. Original string will be modified.
Ns_StrToUpper(string)
Convert string to uppercase. Returns pointer to original string. Original string will be modified.
Ns_StrTrim(string)
Trim leading and trailing white space from string. A pointer to the trimmed string will be returned, which will be in the original
string. Do not lose your original pointer to the string if you later need to free it.
Ns_StrTrimLeft(string)
Trim leading white space from string. A pointer to the trimmed string will be returned, which will be in the original string. Do not
lose your original pointer to the string if you later need to free it.
Ns_StrTrimRight(string)
Trim trailing white space from string. The original string pointer will be returned, but the string will have been modified: a ' 's
will have been placed right after the last non-whitespace character of the string.
Ns_StringPrint(string)
Print a string to stdout.
SEE ALSO nsd(1), info(n)
KEYWORDS AOLserver 4.0 Ns_String(3aolserver)