Sponsored Content
Top Forums Shell Programming and Scripting Search string at a particular position in a file Post 302865957 by Akshay Hegde on Monday 21st of October 2013 12:13:46 AM
Old 10-21-2013
Quote:
Originally Posted by Anamika08
Hi,
i have a text file as :

abc 0 1 Pass
hjk 1 1 Pass
bhk 0 0 Fail
jjh 8 2 Pass
nkji 0 1 Pass

Now I want to check that if 1st column is jjh , then , store the value of 3rd string of that line in a variable. Hence, 2 will be stored.

This way I want value from any line depending upon its first column.



Assuming there won't be any duplicate

try

Code:
$ myvar=$(awk '$1=="jjh"{print $3}' file)

Code:
$ echo $myvar
2

Please use codetag
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Print lines with search string at specific position

Hi Folks, I have a file with all fields defined by byte position, but any field can be empty so I cannot print lines based on a search of specific columns. I need to print all lines of this file where the string of two characters at byte position 100-101 contains the number 27. Any ideas? ... (4 Replies)
Discussion started by: HealthyGuy
4 Replies

2. Shell Programming and Scripting

search in finding position of a string in avariable

Hi, I have to find a text in a variable and need to get the position of it. say, a="This is Example Example1 xxx yyy Example" if i search for "Example" then i should get the location of the starting location "Example". and in next iteration it should give the location of next "Example" ... (2 Replies)
Discussion started by: smr_rashmy
2 Replies

3. Shell Programming and Scripting

Search for a string and replace the searched string in the same position

Hi All, My requisite is to search for the string "0108"(which is the year and has come in the wrong year format) in a particular column say 4th column in a tab delimited file and then replace it with 2008(the correct year format) in the same position where 0108 was found..The issue is the last... (15 Replies)
Discussion started by: ganesh_248
15 Replies

4. Shell Programming and Scripting

search a line and insert string into specific at position

Hi, guys. I have one question: How can I search for a line with certain string in it and then insert a string into this line? For example: There is a file called shadow, the contents of it are below: ************************** ... yuanz:VIRADxMsadfDF/Q:0:0:50:7:::... (9 Replies)
Discussion started by: daikeyang
9 Replies

5. UNIX for Dummies Questions & Answers

Search for a string and replace the searched string in the same position in samefile

Hi All, My requisite is to search for the string "0108"(which is the year and has come in the wrong year format) in a particular column say 4th column in a tab delimited file and then replace it with 2008(the correct year format) in the same position where 0108 was found in the same file..The... (27 Replies)
Discussion started by: ganesh_248
27 Replies

6. UNIX for Dummies Questions & Answers

Search a string in the file and then replace another string after that position

Hi I am looking for a particular string in a file.If the string exists, then I want to replace another string with some other text.Once replaced, search for the same text after that character position in the file. :wall: E.g: Actual File content: Hello Name: Nitin Raj Welcome to Unix... (4 Replies)
Discussion started by: dashing201
4 Replies

7. Shell Programming and Scripting

Search string position in a line

WeeksD1|$26.52|$26.52|03/02/2013|12.48|D1|1.09|0|0|0|0|0|.95|0|0|0|0|0|0|0|0|0|0|0|0|0|0||$0.00|$0.00||0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0||$0.00|$0.00||0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0||$0.00|$0.00||0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|$0.00|$0.00|$0.00|$0.00|$0.00|$0.00|$... (3 Replies)
Discussion started by: gavemani
3 Replies

8. Shell Programming and Scripting

Search a string in a text file and add another string at the particular position of a line

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 and add/replace... (1 Reply)
Discussion started by: suryanarayana
1 Replies

9. Shell Programming and Scripting

Search string within a file and list common words from the line having the search string

Hi, Need your help for this scripting issue I have. I am not really good at this, so seeking your help. I have a file looking similar to this: Hello, i am human and name=ABCD. How are you? Hello, i am human and name=PQRS. I am good. Hello, i am human and name=ABCD. Good bye. Hello, i... (12 Replies)
Discussion started by: royzlife
12 Replies

10. Shell Programming and Scripting

Search for a string at a particular position and replace with blank based on position

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
curl_easy_init(3)						  libcurl Manual						 curl_easy_init(3)

NAME
curl_easy_getinfo - Extract information from a curl session (added in 7.4) SYNOPSIS
#include <curl/curl.h> CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ... ); DESCRIPTION
Request internal information from the curl session with this function. The third argument MUST be a pointer to a long, a pointer to a char * or a pointer to a double (as this documentation describes further down). The data pointed-to will be filled in accordingly and can be relied upon only if the function returns CURLE_OK. This function is intended to get used *AFTER* a performed transfer, all results from this function are undefined until the transfer is completed. AVAILABLE INFORMATION
These are informations that can be extracted: CURLINFO_EFFECTIVE_URL Pass a pointer to a 'char *' to receive the last used effective URL. CURLINFO_HTTP_CODE Pass a pointer to a long to receive the last received HTTP code. CURLINFO_FILETIME Pass a pointer to a long to receive the remote time of the retrieved document. If you get -1, it can be because of many reasons (unknown, the server hides it or the server doesn't support the command that tells document time etc) and the time of the document is unknown. Note that you must tell the server to collect this information before the transfer is made, by using the CURLOPT_FILE- TIME option to curl_easy_setopt(3). (Added in 7.5) CURLINFO_TOTAL_TIME Pass a pointer to a double to receive the total transaction time in seconds for the previous transfer. This time does not include the connect time, so if you want the complete operation time, you should add the CURLINFO_CONNECT_TIME. CURLINFO_NAMELOOKUP_TIME Pass a pointer to a double to receive the time, in seconds, it took from the start until the name resolving was completed. CURLINFO_CONNECT_TIME Pass a pointer to a double to receive the time, in seconds, it took from the start until the connect to the remote host (or proxy) was completed. CURLINFO_PRETRANSFER_TIME Pass a pointer to a double to receive the time, in seconds, it took from the start until the file transfer is just about to begin. This includes all pre-transfer commands and negotiations that are specific to the particular protocol(s) involved. CURLINFO_STARTTRANSFER_TIME Pass a pointer to a double to receive the time, in seconds, it took from the start until the first byte is just about to be trans- fered. This includes CURLINFO_PRETRANSFER_TIME and also the time the server needs to calculate the result. CURLINFO_REDIRECT_TIME Pass a pointer to a double to receive the total time, in seconds, it took for all redirection steps include name lookup, connect, pretransfer and transfer before final transaction was started. CURLINFO_REDIRECT_TIME contains the complete execution time for mul- tiple redirections. (Added in 7.9.7) CURLINFO_REDIRECT_COUNT Pass a pointer to a long to receive the total number of redirections that were actually followed. (Added in 7.9.7) CURLINFO_SIZE_UPLOAD Pass a pointer to a double to receive the total amount of bytes that were uploaded. CURLINFO_SIZE_DOWNLOAD Pass a pointer to a double to receive the total amount of bytes that were downloaded. CURLINFO_SPEED_DOWNLOAD Pass a pointer to a double to receive the average download speed that curl measured for the complete download. CURLINFO_SPEED_UPLOAD Pass a pointer to a double to receive the average upload speed that curl measured for the complete upload. CURLINFO_HEADER_SIZE Pass a pointer to a long to receive the total size of all the headers received. CURLINFO_REQUEST_SIZE Pass a pointer to a long to receive the total size of the issued requests. This is so far only for HTTP requests. Note that this may be more than one request if FOLLOWLOCATION is true. CURLINFO_SSL_VERIFYRESULT Pass a pointer to a long to receive the result of the certification verification that was requested (using the CURLOPT_SSL_VERI- FYPEER option to curl_easy_setopt). (Added in 7.4.2) CURLINFO_CONTENT_LENGTH_DOWNLOAD Pass a pointer to a double to receive the content-length of the download. This is the value read from the Content-Length: field. (Added in 7.6.1) CURLINFO_CONTENT_LENGTH_UPLOAD Pass a pointer to a double to receive the specified size of the upload. (Added in 7.6.1) CURLINFO_CONTENT_TYPE Pass a pointer to a 'char *' to receive the content-type of the downloaded object. This is the value read from the Content-Type: field. If you get NULL, it means that the server didn't send a valid Content-Type header or that the protocol used doesn't support this. (Added in 7.9.4) RETURN VALUE
If the operation was successful, CURLE_OK is returned. Otherwise an appropriate error code will be returned. SEE ALSO
curl_easy_setopt(3) BUGS
Surely there are some, you tell me! libcurl 7.9.7 25 Apr 2002 curl_easy_init(3)
All times are GMT -4. The time now is 08:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy