is there in c# cmd similar to AWK in shell?
root@U2KPriamry # echo " JD2BSC01 BCF-0341 BTS-0707 QUAL "| awk '{print $4}'
BTS-0707
root@U2KPriamry #
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Jan 6, 2015, 3:52 AM EST
Wim SturkenboomRank #2,527 · 554 reputationPosted Jan 6, 2015, 1:26 AM EST
VulpesRank #55 · 29.2K reputationPosted Jan 6, 2015, 5:50 AM EST
VulpesRank #55 · 29.2K reputationPosted Jan 7, 2015, 12:47 AM EST
The File.ReadLines() method reads the lines of the file one by one, without storing them all in memory at the same time, which is important if you have 50,000 lines to read.
For each line, an anonymous 'tuple' is then created consisting of the text of the line and the line number (starting from 1).
These tuples are then filtered so that only those whose 'text' property includes the search word are returned.
The foreach statement then iterates through the filtered tuples and prints to the console the line number and the text of the matched line.
So it sounds like that's what you want.
Abdullah Dhiab22 reputationPosted Jan 5, 2015, 11:16 PM EST
Abdullah Dhiab22 reputationPosted Jan 6, 2015, 2:38 AM EST
Abdullah Dhiab22 reputationPosted Jan 6, 2015, 2:42 AM EST
Abdullah Dhiab22 reputationPosted Jan 6, 2015, 2:56 AM EST
Abdullah Dhiab22 reputationPosted Jan 6, 2015, 4:21 AM EST
Abdullah Dhiab22 reputationPosted Jan 6, 2015, 4:23 AM EST
Abdullah Dhiab22 reputationPosted Jan 6, 2015, 11:49 PM EST
i need to search in text file for a string, if its there get whole line where its located..
i found below example but could not understand it, ideas?
foreach (var match in File.ReadLines(@"c:\LogFile.txt") .Select((text, index) => new { text, lineNumber = index+ 1 }) .Where(x => x.text.Contains("SEARCHWORD"))) { Console.WriteLine("{0}: {1}", match.lineNumber, match.text); }Abdullah Dhiab22 reputationPosted Jan 7, 2015, 6:24 AM EST