I'm trying find and print a number after a specific user passed string in each line of a text file using C (as requested by the powers that be). I've pieced together enough to read the file, find the string and print the line it was found on but I’m not sure where to even start in terms of finding the number after the string. Any tips would be much appreciated.
The below code outputs the line number where the string is found: My text file looks like below. I'm trying to print the number as is the file (2 decimals) after "val=".
Is there any way to print all the string till we get a space and a number and store it a variable
for eg we have string java.io.IOException: An existing connection was forcibly closed by the remote host 12
All I want is to store "java.io.IOException: An existing connection was forcibly closed... (13 Replies)
Hello all,
I need to find the longest string in a select field and print that field.
I have tried a few different methods and I always end up one step from where I need to be.
Methods thus far:
nawk '{if (length($1) > long) long=length($1); if(length($1)==long) print $1}'
The above... (6 Replies)
i have a file that looks like this
ABC123
aaaaaaaaaaaaaaasssssssssssssssffhhh
ABC234
EMPTY
ABC652
jhfffffffffffffffffffffffffffffffffffkkkkkkkkkkkk
i want to grep "EMPTY" and print ABC234 (3 Replies)
Hi
I have requirement to find nth occurrence in a file and capture data from with in lines (between lines)
Data in File.
<QUOTE>
<SESSION>
<ATTRIBUTE NAME='Parameter Filename' VALUE='file1.parm'/>
<ATTRIBUTE NAME='Service Name' VALUE='None'/>
</SESSION>
<SESSION>
<ATTRIBUTE... (6 Replies)
I am trying to go through a file that has a few million lines. I want to only pull lines that contain a number anywhere in the ninth field, but it has to be after a "/" character. Here is my awk:
awk -F\| '$9 ~ /\/*{1,}*/ {print $0}' file1 > file2
However, it is just printing out every... (3 Replies)
Can I do this in one awk session. Solution I have is poor.
I want to return the number after PID.
echo "Start: 12345 is used by PID:11111 username" | awk -F: '{print $3}' | awk '{print $1}' (6 Replies)
Hey All,
I want want to print a string N times the number N before it.
Like i have "20 hello".
so i want to print
hello
hello
hello
.
.
.
.
. 20 times..
Please help me.. I am not able o figure out.. how to do the same? (8 Replies)
Ok I would like to do the following
file test contains the following lines. between the lines ABC there may be any amount of lines up to the next ABC entry.
I want to grep for the filename.txt entry and print the lines in between (and including that line) up to and including the last line... (3 Replies)
Hi
I want to use awk to match where field 3 contains a number within string - then print the line and just the number as a new field.
The source file is pipe delimited and looks something like
1|net|ABC Letr1|1530|||
1|net|EXP_1040 ABC|1121|||
1|net|EXP_TG1224|1122|||
1|net|R_North|1123|||... (5 Replies)
Discussion started by: Mudshark
5 Replies
LEARN ABOUT MINIX
strtol
STRTOL(3) Linux Programmer's Manual STRTOL(3)NAME
strtol, strtoll, strtoq - convert a string to a long integer
SYNOPSIS
#include <stdlib.h>
long int strtol(const char *nptr, char **endptr, int base);
long long int strtoll(const char *nptr, char **endptr, int base);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
strtoll():
_ISOC99_SOURCE
|| /* Glibc versions <= 2.19: */ _SVID_SOURCE || _BSD_SOURCE
DESCRIPTION
The strtol() function converts the initial part of the string in nptr to a long integer value according to the given base, which must be
between 2 and 36 inclusive, or be the special value 0.
The string may begin with an arbitrary amount of white space (as determined by isspace(3)) followed by a single optional '+' or '-' sign.
If base is zero or 16, the string may then include a "0x" or "0X" prefix, and the number will be read in base 16; otherwise, a zero base is
taken as 10 (decimal) unless the next character is '0', in which case it is taken as 8 (octal).
The remainder of the string is converted to a long int value in the obvious manner, stopping at the first character which is not a valid
digit in the given base. (In bases above 10, the letter 'A' in either uppercase or lowercase represents 10, 'B' represents 11, and so
forth, with 'Z' representing 35.)
If endptr is not NULL, strtol() stores the address of the first invalid character in *endptr. If there were no digits at all, strtol()
stores the original value of nptr in *endptr (and returns 0). In particular, if *nptr is not '