problem with grep in combination with xargs


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers problem with grep in combination with xargs
# 15  
Old 12-23-2008
Hi Methyl,
file NY5876_cds.csv looks like this it hasn't got the > symbol in front of each line
NY5876_1 chromosomal replication initiation protein
NY5876_2 DNA polymerase III subunit beta
NY5876_3 recombination protein F
NY5876_4 DNA gyrase subunit B
NY5876_5 type I restriction-modification system, M subunit, putative
NY5876_6 type I restriction-modification system S subunit
NY5876_7 hypothetical protein PSPTO_0007
NY5876_8 HsdR family type I site-specific deoxyribonuclease
NY5876_9 ISPsy3, transposase
NY5876_10 hypothetical protein PSPTO_0011
....
NY5876_9999 hypothetical protein
# 16  
Old 01-08-2009
Bruno, now we know that the fields are separated by a single tab not a space we need to take that into account. If we generate the TAB character it makes it clear what we are doing.

Code:
By the way, one quick way of making tabs visible in a text file is:
sed -n l myfilename

(
#!/bin/ksh
TAB=`echo "\0011"`    # TAB Character
cat file_2|while read TAG
do
        grep \^"${TAG}${TAB}" file_1
done
) > test_file

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem with xargs

I entered the following <zzz.list xargs showtell |more which does a echo "<<<<<<<<<<<<<<<<<<<<<<<<< $1 >>>>>>>>>>>>>>>>>>" head -20 $1 The file zzz.list contains 525 lines representing user scripts (1 per line), but only the first, 181st, and 399th lines were processed. What am I missing? TIA (2 Replies)
Discussion started by: wbport
2 Replies

2. Shell Programming and Scripting

Looping grep and xargs

In a directory I have two lists, all files which could contain certain fields (they all share copied code) and a list of fields. My two scripts are <appl.list xargs grep $1 where appl.list contains files (source programs) with the fields. This script is named YY <fields.list xargs YY ... (4 Replies)
Discussion started by: wbport
4 Replies

3. Shell Programming and Scripting

Problem using xargs with rm

I am trying to call xargs, however rm is complaining find . -maxdepth 1 -name "*tests*" -print0 | xargs -0 rm rm: missing operand Try `rm --help' for more information. (3 Replies)
Discussion started by: kristinu
3 Replies

4. Shell Programming and Scripting

Find common terms in two text file, xargs, grep

Hello, I'm interested in finding all occurrences of the terms in file1 in file2, which are both csv files. I can do this with a loop but I'm interested in knowing if I can also do it with the help of xargs and grep. What I have tried: cat file1 | xargs grep file2 The problem is that... (15 Replies)
Discussion started by: eon
15 Replies

5. Shell Programming and Scripting

Using a combination of sort/cut/grep/awk/join/paste/sed

I have a file and need to only select users that have a shell of “/bin/bash” in the line using awk or sed please help (4 Replies)
Discussion started by: boyboy1212
4 Replies

6. Shell Programming and Scripting

xargs problem

Hi From the xargs man page (Solaris): ls $1 | xargs -I {} -t mv $1/{} $2/{} This would move all the files in directory $1 to directory $2 Problem 1: In a shell script if I want to move files in d1 to d2 dir1=~/d1 dir2=~/d2 ls $dir1 | xargs -I {} -t mv $dir1/{} $dir2/{} does not... (3 Replies)
Discussion started by: encrypted
3 Replies

7. Shell Programming and Scripting

Sed Awk Cut Grep Combination Help ?

I have been reading for a few hours trying to educate myself enough to accomplish this task, so please know I have performed some research. Unfortunately, I am not a *NIX scripting expert, or a coder. I come from a network background instead. SO, here is my desired outcome. I have some Cisco... (5 Replies)
Discussion started by: abbzer0
5 Replies

8. UNIX for Dummies Questions & Answers

Grep and find combination

Hello All, I'm trying the following:find . -name "*" -exec grep -ln "IsAlpha" {} \; It gives me file names only (having string "IsAlpha"), I want to get line numbers also, something like this: test 1: Line 52 test 1: Line 95 etc Is it possible to obtain using grep & find only. (5 Replies)
Discussion started by: nervous
5 Replies

9. UNIX for Dummies Questions & Answers

Combination of find -xargs & wc -l

Dear all, I have to calculate sum of record count of files of the specified directory. First I tried the following way which prints one or more outputs. How can I sum of this output? find /home/work/tmp/1/O/ -type f -print0 | xargs -0 wc -l | grep total 1666288 total 1073908 total ... (4 Replies)
Discussion started by: mr_bold
4 Replies

10. Shell Programming and Scripting

grep and xargs

guys... I wanna use xargs in such a way that i can use it in grepping the fileds.. something like this: grep -p <xargs values> * lemme know how to do this.. (5 Replies)
Discussion started by: freakygs
5 Replies
Login or Register to Ask a Question