Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Basic awk question...getting awk to act on $1 of the command itself Post 302303219 by Franklin52 on Thursday 2nd of April 2009 06:57:53 AM
Old 04-02-2009
You are confused with the the first parameter of the script and the first field of awk. To print the first word of the shell parameter with awk it should be something like:

Code:
echo "$1" | awk '{print $1}'

Regards
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

awk and find command question

Hello! I have written this script: for file in "$( find $dirName -type d )" do echo "$file" echo "hello" done but as a result I get all the directories and in the end the work "hello". Shouldn't it print the word "hello" after printing the name of each directory and not in the end? ... (1 Reply)
Discussion started by: GeorgeP
1 Replies

2. UNIX for Dummies Questions & Answers

Basic IF Command Question

Hi, I have a months worth of data that I need to separate into weekly files. There is a date column with dates in the following format: YYYYMMDD. I'm thinking I can create the weekly files by using a grep command combined with an IF command and specify each day of the specific week I'm... (1 Reply)
Discussion started by: cwl
1 Replies

3. Shell Programming and Scripting

awk script need to act on same file on matced case

Hello, I have a log file , i want to delete the lines of the log file which is match with 1st and 5th field with different patterns. Once it will meet with that condition it will delete that line from the log . I dont want to create any temp file over there. Successfully able to retrieve the... (1 Reply)
Discussion started by: posix
1 Replies

4. UNIX for Dummies Questions & Answers

AWK printf command question

Hi, I am using below awk code to convert a csv file data into fixed file format. awk 'BEGIN { FS = "," fmt = "%10s%010d%10s%d%1d\n" } NR>1 { printf fmt, $1, $2, $3, $4*100, $5 }' /data/mydata.csv > /data/fixed.dat Data in mydata.csv ================... (1 Reply)
Discussion started by: kbmkris
1 Replies

5. Shell Programming and Scripting

AWK printf command question

Hi, I am using below awk code to convert a csv file data into fixed file format. awk 'BEGIN { FS = "," fmt = "%10s%010d%10s%d%1d\n" } NR>1 { printf fmt, $1, $2, $3, $4*100, $5 }' /data/mydata.csv > /data/fixed.dat Data in mydata.csv ================... (2 Replies)
Discussion started by: kbmkris
2 Replies

6. IP Networking

iptables nat/masquerade - how to act as a basic firewall?

edit: SOLVED - see below for solution Hi there, I've inherited a gob of Linux hosts and so am learning linux from the bottom of the deep end of the pool (gotta say I'm warming up to Linux though - it's not half bad) Right now iptables is confusing me and I could use some pointers as to how... (0 Replies)
Discussion started by: Smiling Dragon
0 Replies

7. Shell Programming and Scripting

Question about a awk command

Hi, I am studying an awk command: awk '{ sub(/\/\/.*/, "", $NF); print }' input.txt The input.txt is: char*s1="//hello"; //comment //delete /* hello //*/ The output is : char*s1="//hello"; /* hello (2 Replies)
Discussion started by: jeffwang66
2 Replies

8. UNIX for Dummies Questions & Answers

Basic loop awk/shell script question..

Hi, Sorry if this is a newbie question. I guess you can use either awk or shell script for this sequence of operations, but knowing very little about either of them I'm not sure how I should try to write this. The basic objective is to copy certain files that are scattered all over my... (10 Replies)
Discussion started by: pc2001
10 Replies

9. Homework & Coursework Questions

Question about awk command

hi gurus, I am not sure what the below commands does. awk 'BEGIN {sum=0} {sum=sum+$5} END {print sum}' input_file (4 Replies)
Discussion started by: ramkumar15
4 Replies

10. UNIX for Beginners Questions & Answers

Basic Linux command line question

:D:D:D These are list of command i typed on opensuse terminal and evolve lots of doubt around ,that i can't answer. COMMAND 1 linux-xavv:/ # cd COMMAND 2 linux-xavv:~ # Does above command 1 and command two with red labelled sign make different meaning or same . 1 linux-xavv:/... (1 Reply)
Discussion started by: lobsang
1 Replies
IGAWK(1)							 Utility Commands							  IGAWK(1)

NAME
igawk - gawk with include files SYNOPSIS
igawk [ all gawk options ] -f program-file [ -- ] file ... igawk [ all gawk options ] [ -- ] program-text file ... DESCRIPTION
Igawk is a simple shell script that adds the ability to have ``include files'' to gawk(1). AWK programs for igawk are the same as for gawk, except that, in addition, you may have lines like @include getopt.awk in your program to include the file getopt.awk from either the current directory or one of the other directories in the search path. OPTIONS
See gawk(1) for a full description of the AWK language and the options that gawk supports. EXAMPLES
cat << EOF > test.awk @include getopt.awk BEGIN { while (getopt(ARGC, ARGV, "am:q") != -1) ... } EOF igawk -f test.awk SEE ALSO
gawk(1) Effective AWK Programming, Edition 1.0, published by the Free Software Foundation, 1995. AUTHOR
Arnold Robbins (arnold@skeeve.com). ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +--------------------+-----------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +--------------------+-----------------+ |Availability | SUNWgawk | +--------------------+-----------------+ |Interface Stability | Volatile | +--------------------+-----------------+ NOTES
Source for gawk is available on http://opensolaris.org. Free Software Foundation Nov 3 1999 IGAWK(1)
All times are GMT -4. The time now is 04:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy