[Solved] Help with awk


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers [Solved] Help with awk
# 1  
Old 06-07-2013
[Solved] Help with awk

Hi All,


I have been using the below syntax in unix and it has been working fine, Later when we migrated to Linux by having folder wise pemission its not working fine. So can you let us know where the list file could be created ?


Code:
awk '/^XXX/{key=$0;print > "list";next} /^YYY/ {print key $0}'  File1 >  File2

awk: (FILENAME=/data/new/home/ FNR=1) fatal: can't redirect to `list' (Permission denied)




Thanks in advance for your assitance

Last edited by Scott; 06-07-2013 at 11:41 AM.. Reason: Please use code tags
# 2  
Old 06-07-2013
It means what it says: It doesn't have permission to write to that file. This is not related to the program you're running.

ls -ld foldername and ls -ld list might help explain why.
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 06-07-2013
Try adding "\" before ">":

awk '/^XXX/{key=$0;print \> "list";next} /^YYY/ {print key $0}' File1 > File2

---------- Post updated at 02:57 PM ---------- Previous update was at 02:54 PM ----------

Please ignore my previous post, I misunderstood your question.

Last edited by juzz4fun; 06-07-2013 at 03:56 PM.. Reason: Ignore this post
# 4  
Old 06-07-2013
It cannot write the file "lists" in the current work directory.
Check file permissions!
Code:
ls -la

This User Gave Thanks to MadeInGermany For This Post:
# 5  
Old 07-19-2013
Thanks everyone it was indeed a permission issue, I redirected the input a valid folder with permission and it worked fine.

Moderator's Comments:
Mod Comment edit by bakunin: thanks for the follow-up. I set the thread to "Solved".

Last edited by bakunin; 07-19-2013 at 02:50 PM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Solved] awk Errors on notation

can someone spot what i'm doing wrong here: awk 'BEGIN{printf("%0.2f", 1 / 2649320) * 100}' i get this error: awk: line 1: syntax error at or near * then i do this and get the answer i'm trying to avoid: awk 'BEGIN{print(1 / 2649320) * 100}' 3.77455e-05 (7 Replies)
Discussion started by: SkySmart
7 Replies

2. UNIX for Dummies Questions & Answers

[Solved] awk oddity

I have to apologize for my ignorance so this question is probably stupid. How does awk process a file? Does it read from top of input file to end of file going line by line? Yoda helped me create an awk script that helps me parse the named.conf file and output it into a .csv file but when... (8 Replies)
Discussion started by: djzah
8 Replies

3. Shell Programming and Scripting

[Solved] Using awk to calculate max value

I have a file of sites and each site has a variable number of flow values with a date for each value. I want to determine the max value of flow for each site and output the site number, max value, and date of max value.The format structure (simplified) is the following: Record Site Number ... (5 Replies)
Discussion started by: cparr
5 Replies

4. UNIX for Dummies Questions & Answers

[Solved] awk FS

I have a script which uses awk to read from a file seperated with commas, although saved as a .conf file. awk -F, '{print $3}' it is meant to pick up "a label here" (for example) But instead return "a" Problem is that although the command does recognise the comma seperation it still... (1 Reply)
Discussion started by: Pedro72
1 Replies

5. UNIX for Dummies Questions & Answers

[Solved] To the power of using awk

Hi Guys, I got stuck to a a point where I need to find the value for (4 to the power of -2 upto 8 places after decimal .... 4^(-2) ; the result I need is upto 8 places after decimal. How is that possible? Thanks a lot!! (2 Replies)
Discussion started by: Indra2011
2 Replies

6. Shell Programming and Scripting

[Solved] HP-UX awk sub multiple patterns

Hi, I am using sub to remove blank spaces and one pattern(=>) from the input string. It works fine when I am using two sub functions for the same. However it is giving error while I am trying to remove both spaces and pattern using one single sub function. Working: $ echo " OK => " |awk... (2 Replies)
Discussion started by: sai_2507
2 Replies

7. Shell Programming and Scripting

[Solved] awk string with spaces

Why does this work: awk -v s="this is a string" 'index($0, s)' file while the following doesn't? s="this is a string" awk -v s=$s 'index($0, s)' file How do I search for a string with spaces in it? ---------- Post updated at 01:18 AM ---------- Previous update was at 01:15 AM ----------... (0 Replies)
Discussion started by: locoroco
0 Replies

8. Shell Programming and Scripting

[Solved] Split file using awk

hlow all, need your advice i have sample.txt 1252468812,yahoo,3.5 1252468812,hotmail,2.4 1252468819,yahoo,1.2 1252468812,msn,8.9 1252468923,gmail,12 1232468819,live,3.4 1252368929,yahoo,9.0 1252468929,msn,1.2now i want filtering with awk so output will like this 12524_log.txt... (2 Replies)
Discussion started by: zvtral
2 Replies

9. Shell Programming and Scripting

Solved: AWK SED HELP

Hi, I need to process a file as below. Could you please help to achieve that using awk/sed commands. Input file: --------------- AB | "abcdef 12345" | 7r5561451.pdf PQRST | "fghfghf hgkjgtjhghb ghhgjhg hghjghg " | 76er6ry.pdf 12345 | "fghfgcv uytdywe bww76 jkh7dscbc 78 : nvchtry hbuyt"... (0 Replies)
Discussion started by: viveksr
0 Replies

10. Shell Programming and Scripting

can this been solved with awk and sed?

Hi Masters, ___________________________________________________________________________________ Group of orthologs #1. Best score 3010 bits Score difference with first non-orthologous sequence - yeast:3010 human:2754 YHR165C 100.00% PRP8_HUMAN 100.00%... (16 Replies)
Discussion started by: mskcc
16 Replies
Login or Register to Ask a Question