Hello, I'm quite a noobie in programming in UNIX
and I was wondering if it is possible to use 'grep' or similar method
to find PATTERNS from designated location (of charactor)
for example
|param 1 ||param2 |
andrew kim josh
daniel kim michelle
michelle andrew kim
I hope to be able to search up
kim and display only the first 2 lines not the 3rd
i know that cut has -c1-10 so you can specify charactor to cut
but can the grep or other things be done the same? and display the whole line?
So to clarify, you are wanting to only match lines that have (for example) 'kim' in the first or second field, but display the entire line where it's matched, right?
If so, you'll need a little bit of logic around the grep:
and REALLY sorry but i have a small problem
when i do read by line
my ' '(space x 10) is same as ' ' (space x1)
is there a way to keep the spaces as it is while
reading line by line?
thanks (this is important because i cannot use delim as some are like JenniferKim 2 params are stuck together)
I think I follow what you mean...
If you need something to appear in the forums as you've typed it, surround it with CODE tags (the "#" symbol in the editor).
/dev/null is just a garbage can, it means that I want the output from grep to go nowhere as we don't need it. You can get a similar effect by using grep with the -q option but that only wroks on certain versions of grep.
If your fields are exactly 8 chars wide, we can change the cut call in the code like so:
Becomes
(ie, instead of cutting fields 1 and 2 seperated by spaces, we cut chars 1-8 and 9-16)
If we're talking about formatting problems, you must use CODE tags or we'll never understand what you are after.
However, If you want echo to not contract spaces, add quotes around the params passed to it:
Becomes
I have a file xyz with the following content
PPPL 0123
PPPL 0006
POFT 0923
POFT 1111
WENT 2323
SEND 2345
I also have another file named MasterFile where it contains the above mentioned data million times with different digits at the end for example some times it contains SEND 9999 or WENT... (4 Replies)
Hi Gurus,
I forgot the command which can insert one character multiple times. for example: I need 50 "#"
#############...
I used the command before, it is very convenient.
anybody can help this.
thanks in advance. (1 Reply)
Dear all,
I have gone through all the search and replace requests but none of them meet my particular need. I have a huge file in which all Unicode characters are stored as Names. A sample is given below. I want to replace strings in that file with a mapper from another file termed as master.dic. ... (4 Replies)
Hi Gurus,
I need to check the charactor in certain position.
in my file
abcdef1234gh
ac1234eeeegt
acdead1235gh
I want to check what is check from position 7 to 10's charactor, if it is 1234, then output the whole line. for above file, I want to get below output
abcdef1234gh... (2 Replies)
How do I use awk to search for a string that contains a space bar?
I have tried this
awk '/send email/ {print $0}' input
awk '/send\ email/ {print $0}' input (1 Reply)
Hi,
I am trying to grep a string which has two words separated by space.
I used a script to grep the string by reading the string in to a variable
command i used in the script is
echo "enter your string"
read str
grep $str <file>
it is working fine when the entered string is a single... (3 Replies)
Hi,
i have to search for a char like that :
export var1="i am not happy /not happy"
with a command like :
grep $var1 file
but this not working with me !!!
thank you in advance. (2 Replies)
Hi,
I need to send "^[" command to the buffer.
I tried to use insert within VIM and press 'ctrl' key and then '^' and '[' key.
but it didn't work.
Does anyone know how to do it?
Thanks a lot!
Julie (2 Replies)
If in my search string with awk, if I have spaces, I am getting an awk error.
e.g. awk /A B/ filename
How can I search the pattern which has space within? (1 Reply)