how to grep a file and cut a corresponding value from the line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to grep a file and cut a corresponding value from the line
# 1  
Old 12-12-2008
how to grep a file and cut a corresponding value from the line

i have to grep a file which has contents like

/Source/value/valuefile/readme.txt DefaultVersion:=1.7

I have to grep this file with "/Source/value/valuefile/readme.txt" and cut the corresponding value "1.7" from the same line

i tried grep and cut but not working.
# 2  
Old 12-12-2008
in awk and if your file is in the same format as the given example then you could try this
Code:
awk -F"=" '/\/Source\/value\/valuefile\/readme.txt/ {print $2}' filename

or with grep and cut
Code:
grep "/Source/value/valuefile/readme.txt" filename|cut -d"=" -f2

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cut line from searched file if grep find neighbor columns

Hello All, While searching for the question, I found some answers but my implementation is not giving expected output. I have two files; one is sourcefile, other is named template. What I want to do is to search each line in template, when found all columns, cut the matching line from source... (4 Replies)
Discussion started by: baris35
4 Replies

2. Shell Programming and Scripting

cut the variable from the line and use it to find the file and read the content of that file

Hi, I am working on one script..I am having files in the below format file 1 (each line is separated with : delimeter) SPLASH:SPLASH:SVN CIB/MCH:MCH:SVN Now I want from file 1 that most left part of the first line will store in... (6 Replies)
Discussion started by: rohit22hamirpur
6 Replies

3. Shell Programming and Scripting

cut certain characters for each line in a file

Hi Everyone, i have a file 1.txt <a><a"" dd>aaaaauweopriuew</f><">!(^)!</aa></ff> <a><a"" dd>bbbbbuweopriuew</f><">!(^*)!</aa></ff> i know i can use perl -p -i -e "s/>aaaaa/aa/g" 1.txt perl -p -i -e "s/>bbbbb/bb/g" 1.txt to acheive only keep the first two characters of the five characters,... (4 Replies)
Discussion started by: jimmy_y
4 Replies

4. Slackware

How should I cut this line using cut and grep?

not sure how to do it. wan't to delete it using cut and grep ince i would use it in the shell. but how must the command be? grep "64.233.181.103 wwwGoogle.com" /etc/hosts | cut -d the delimeter is just a space. can you help meplease. :D (1 Reply)
Discussion started by: garfish
1 Replies

5. Shell Programming and Scripting

cut the second line in a text file

Hi I have some problem to cut out the second line in a output file and send to a new file it's a #!/bin/bash script 1 something 2 something 3 something and after I cut 1 something 3 something New file 2 something Thanks in advance (7 Replies)
Discussion started by: pelle
7 Replies

6. Shell Programming and Scripting

How can i cut first line of a file

i want to cut first line of a file and use it.It should remove that line from file content.Plz help me (7 Replies)
Discussion started by: arghya_owen
7 Replies

7. Shell Programming and Scripting

how to cut a field of a line in a text file?

Hi, I have text file which contains lines like : a/a/a/a/.project b/b/b/b/b/.project c/c/c/.project d/.project e/e/e/e/.project i want for all lines the last word .project should be removed and the file should look like : a/a/a/a/ b/b/b/b/b/ c/c/c/ .... how to proceed... (7 Replies)
Discussion started by: bhaskar_m
7 Replies

8. Shell Programming and Scripting

how to cut first 3 characters of each line in a file

Hi Friends I have a file like sample1.txt ------------ 10998909.txt 10898990.txt 1898772222.txt 8980000000000.txt I need to take first 3 characters of each line in a file and i need to print it ' like loop 109 108 189 898 (7 Replies)
Discussion started by: kittusri9
7 Replies

9. Shell Programming and Scripting

grep & cut the file

I need to grep and cut the some file in the folder and output to some file. the sample file looks like below -rw-r--r-- 1 gui gui 28050789 Jun 25 18:38 mymkzpiii.txt -rw-r--r-- 1 gui gui 127983856 Jun 25 18:39 phmnlpiii.txt i need the output like below ... (3 Replies)
Discussion started by: aboorkuma
3 Replies

10. UNIX for Dummies Questions & Answers

Cut a file from line 5745960?

How would I do this simple task? I have a pretty big file, too big to edit in a text editor. I found the line number I need to start with, 5745960. Now I want to say to Unix, give me every line from 5745960 to the end. It seems pretty easy but I can't figure out a simple way to do it. ... (2 Replies)
Discussion started by: LordJezo
2 Replies
Login or Register to Ask a Question