Using key words or symbols to determine parser


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Using key words or symbols to determine parser
# 8  
Old 03-18-2015
what was the reason for changing FILENAME to DEL_Position.txt ?
Also, if you're on Solaris, use nawk instead of awk.
# 9  
Old 03-18-2015
To specify the filename, though I am not sure. DEL_position.txt is the file containing the "del" in it. Thank you Smilie

Code:
  awk 'FNR==1 {next} match($1,/\.[0-9]+del[ACGT]+/) {print "del: ", FILENAME, substr($1, RSTART+RLENGTH-1)} /\.[0-9]+[ACGT]+>[ACGT]+/ {print ">: ",FILENAME}' DEL_position.txt[34]>:  file3 del:  file4 G

# 10  
Old 03-18-2015
FNR==1 can't be a syntax error. Sure you posted the entire command and error msg?
You need to double quote the "DEL_Position.txt" if it should serve as a file name.
# 11  
Old 03-18-2015
Code:
 awk 'FNR==1 {next} match($1,/\.[0-9]+del[ACGT]+/) {print "del: ", "DEL_position.txt", substr($1, RSTART+RLENGTH-1)} /\.[0-9]+[ACGT]+>[ACGT]+/ {print ">: ","DEL_position.txt"}' "DEL_position.txt">:  "DEL_position.txt" del:  "DEL_parse.txt" G
awk: cmd. line:1: fatal: cannot open file `del:' for reading (No such file or directory)

"DEL_position.txt" is the input file with the "del"

"DEL_parse.txt" is the parsed output file

Thank you Smilie.
# 12  
Old 03-18-2015
Quote:
Originally Posted by cmccabe
Code:
 awk 'FNR==1 {next} match($1,/\.[0-9]+del[ACGT]+/) {print "del: ", "DEL_position.txt", substr($1, RSTART+RLENGTH-1)} /\.[0-9]+[ACGT]+>[ACGT]+/ {print ">: ","DEL_position.txt"}' "DEL_position.txt">:  "DEL_position.txt" del:  "DEL_parse.txt" G
awk: cmd. line:1: fatal: cannot open file `del:' for reading (No such file or directory)

"DEL_position.txt" is the input file with the "del"

"DEL_parse.txt" is the parsed output file

Thank you Smilie.
looks like the error message is very descriptive....
The way you're passing your input files is very questionable.
Good luck
This User Gave Thanks to vgersh99 For This Post:
# 13  
Old 03-19-2015
Quote:
Originally Posted by cmccabe
To specify the filename, though I am not sure. DEL_position.txt is the file containing the "del" in it. Thank you Smilie

Code:
awk     'FNR==1         {next}                                  # skip header
         match($1,/\.[0-9]+del[ACGT]+/) {print "del: ",         # find the "del" substring in the last part of $1
                         FILENAME, substr($1, RSTART+RLENGTH-1)}# correct: use FILENAME here to show which file "del" was in. 
         /\.[0-9]+[ACGT]+>[ACGT]+/ {print ">: ",FILENAME}       # correct: use FILENAME here to show which file ">" was in. 
        ' DEL_position.txt[34]>:  file3 del:  file4 G           # supply ONLY filenames and variable definitions in the form OFS="|"
#                                                   ^ wrong!    On top: Does file4 exist? 
#                                       ^^^^ wrong!             On top: Does file3 exist?
#                             ^^ wrong!                         On top: Do DEL_position3 and ...4  exist?

I strongly recommend to read and understand awk and regex man pages!
This User Gave Thanks to RudiC For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

How to block some key words in my url for apache config?

Hi Folks, I am running a website and that needs to be tightened with security in terms of hacking... Whereas, In my URL, when i click on certain links the entire link as contains some words like below:/control_panel /controlpanel /admin /cms Whereas, i need to block those words in apache... (1 Reply)
Discussion started by: gsiva
1 Replies

2. Shell Programming and Scripting

sed parser behaving strange on replacing multiple words in multiple files

I have 4000 files like $cat clus_grp_seq10_g.phy 18 1002 anig_OJJ65951_1 ATGGTTTCGCAGCGTGATAGAGAATTGTTTAGGGATGATATTCGCTCGCGAGGAACGAAGCTCAATGCTGCCGAGCGCGAGAGTCTGCTAAGGCCATATCTGCCAGATCCGTCTGACCTTCCACGCAGGCCACTTCAGCGGCGCAAGAAGGTTCCTCG aver_OOF92921_1 ... (1 Reply)
Discussion started by: sammy777888
1 Replies

3. Shell Programming and Scripting

Delete lines containing key words dynamically

Hi Frens, I have a requirement where I need to delete lines having key words and am using the below command to do that sed '/UNIX/d' inputfile > output But now I have one more requirement where in there will be one reference file which has the ID's to be deleted from the master file. ... (3 Replies)
Discussion started by: weknowd
3 Replies

4. UNIX for Beginners Questions & Answers

Non-root script used search and list specific key words

Hy there all. Im new here. Olso new to terminal & bash, but it seams that for me it's much easyer to undarsatnd scripts than an actual programming language as c or anyother languare for that matter. S-o here is one og my home works s-o to speak. Write a shell script which: -only works as a... (1 Reply)
Discussion started by: Crisso2Face
1 Replies

5. UNIX for Dummies Questions & Answers

Delete lines according to a key words in that line

HI, I have a file A like this: c 1 length 14432 width 3434 temp 34 c 2 length 3343 width 0923 height 9383 hm 902 temp34 c 3 length 938 height 982 hm 9292 temp 23 ... (2 Replies)
Discussion started by: the_simpsons
2 Replies

6. UNIX for Dummies Questions & Answers

Filter logs for key words and create an index

well, im a total novice of unix commands and shell scripting, i never made anything. But yesterday in my work i was working with a lot of log files and i was wondering if there is a command for doing something like this: i have a bunch of files with text like this: blablabla errorcode1... (11 Replies)
Discussion started by: matius_88
11 Replies

7. Shell Programming and Scripting

Extract key words and print their values

Input file (HTTP request log file): GET... (2 Replies)
Discussion started by: buptwy
2 Replies

8. Shell Programming and Scripting

grep - Extracting multiple key words from stdout

Hello. From command line, the command zypper info nxclient return a bloc of data : linux local # zypper info nxclient Loading repository data... Reading installed packages... Information for package nxclient: Repository: zypper_local Name: nxclient Version: 3.5.0-7 Arch: x86_64... (7 Replies)
Discussion started by: jcdole
7 Replies

9. Shell Programming and Scripting

removing the words with symbols in a file in unix

I have file like below Hi iam author <br>joseph</br> in france. I live in my home <br></br> but no food. I will play footbal <br></br> but i wont play cricket. I will read all the books <br>all fiction stories</br> i hate horror stories. I want output like below Hi iam author... (3 Replies)
Discussion started by: vinothsekark
3 Replies

10. Shell Programming and Scripting

deleting symbols and characters between two words

Hi Please tell me how could i delete symbols, whitespaces, characters, words everything between two words in a line. Let my file is aaa BB ccc ddd eee FF kkk xxx 123456 BB 44^& iop FF 999 xxx uuu rrr BB hhh nnn FF 000 I want to delete everything comes in between BB and FF( deletion... (3 Replies)
Discussion started by: rish_max
3 Replies
Login or Register to Ask a Question