Find exact string
Hi Guys,
File is containing data Col1 Col2 ListPrice,List Price Price,Average Selling Price - Actual ProjPrice,Average Selling Price ProjPrice,Launch Price ProjCost,Cost PriceFact,Cost-Actual Now i need to print col2 on the basis of col1 i.e if i Pass Price it should display only "Average Selling Price - Actual" I tried using grep which print first 4 lines like. cat StrykerData_Cubes.csv |grep "Price" | cut -d "," -f2 | tr -s " " "_" even sed command like cat StrykerData_Cubes.csv |grep -w "Price" | sed /^Price/p Edit/Delete Message |
grep '^Price,' file.csv|cut -d',' -f2
|
This command will search the beginning of the string so if file is
Col1 Col2 ListPrice,List Price Price,Average Selling Price - Actual ProjPrice,Average Selling Price ProjPrice,Launch Price ProjCost,Cost ProjCostAct,Cost-Actual For the col1 value as ProjCost if returns last 2 rows whereas it should display only the 5th row. |
Actually, you missed the fact I included the comma at the end of the match string to avoid that problem
;) |
Quote:
Hey thanks. I understood line. and this solved my problem. |
All times are GMT -5. The time now is 08:12 PM. |