Sponsored Content
Top Forums Shell Programming and Scripting Read input file with in awk script not through command line Post 302824643 by zaxxon on Friday 21st of June 2013 08:48:57 AM
Old 06-21-2013
I am not sure if I understand - the explanation seems so simple in regards to your former thread https://www.unix.com/shell-programmin...ent-lines.html

Anyway, you use awk in a shell script the same way as you do that in a shell.
In your code like example, you used -f to give awk a script file. The last argument is always the file name of the file to be processed (for example data, logs...).

Code:
awk '{print $1}' infile > outfile
#or
awk '{print $1 >> outfile}' infile

I am not sure if this hits what you are looking for - else a bit more detailed explanation could help, or maybe another poster understands it, sorry.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

read a file as input and pass each line to another script

Hi, I am trying to write a ftp script which will read a file for filenames and ftp those files to another server. Here's my ftp script, but it's scanning the current directory for file names. My question is how can I pass multiple files (these files will have the name of data files that need to... (0 Replies)
Discussion started by: sajjad02
0 Replies

2. Shell Programming and Scripting

How can I send the input of a read line command through a shell script

Hi All, I wish to automate the unix command 'su' through a shell script. I would like to pass the content of a file as password to 'su' command. My script is as below, #! /bin/sh su userA while read line do rpm -ivh $line done < pwd.txt where pwd.txt contains the password of... (6 Replies)
Discussion started by: little_wonder
6 Replies

3. Shell Programming and Scripting

sed to read line by line and input into another file

I have two files. Fileone contains text string one text string two text string three Filetwo contains Name: Address: Summary: Name: Address: Summary: Name: Address: Summary: I would like to use sed to read each line of file one and put it at the end of the summary line of file... (3 Replies)
Discussion started by: dolacap
3 Replies

4. Shell Programming and Scripting

awk script file command line options

Being new to awk I have a really basic question. It just has to be in the archives but it didn't bite me when I went looking for it. I've written an awk script, placed it in a file, added the "#!/usr/bin/awk -f" at the top of the script and away I go. "% myAwk <inputfile>" gives me exactly what... (2 Replies)
Discussion started by: tomr2k
2 Replies

5. UNIX for Dummies Questions & Answers

Bash script to delete file input on command line

1) I wrote a script and gave the desired permissions using "chmod 755 scriptname". Now if i edit the script file, why do i need to set the permission again? Didn't i set the permission attribute.. or if i edit the file, does the inode number of file changes? 2) I am running my unix on a server... (1 Reply)
Discussion started by: animesharma
1 Replies

6. Shell Programming and Scripting

Script to read command line input and change it to some form

Hi, I want to write a small code in which script changes command line input to some form. Example script.sh a1 a2 a3 a4 ..... output should be "a1|a2|a3|....." Number of inputs in command line can be any variable (2 Replies)
Discussion started by: Raza Ali
2 Replies

7. Shell Programming and Scripting

How to read a two files, line by line in UNIX script and how to assign shell variable to awk ..?

Input are file and file1 file contains store.bal product.bal category.bal admin.bal file1 contains flip.store.bal ::FFFF:BADC:CD28,::FFFF:558E:11C5,6,8,2,1,::FFFF:81C8:CA8B,::FFFF:BADC:CD28,1,0,0,0,::FFFF:81C8:11C5,2,1,0,0,::FFFF:81DC:3111,1,0,1,0 store.bal.... (2 Replies)
Discussion started by: veeruasu
2 Replies

8. Shell Programming and Scripting

How to read each line from input file, assign variables, and echo to output file?

I've got a file that looks like this (spaces before first entries intentional): 12345650-000005000GL140227 ANNUAL HELC FEE EN 22345650-000005000GL140227 ANNUAL HELC FEE EN 32345650-000005000GL140227 ANNUAL HELC FEE EN I want to read through the file line by line,... (6 Replies)
Discussion started by: Scottie1954
6 Replies

9. Shell Programming and Scripting

Error to Read Input from command line

Team , I am trying to write a case condition for database backups.But I am unable to make the script to read input from command line . while true ;do read -p "Do You Wish To Take Database Backup ?? " yn case $yn in *) echo " YES take backup ";; *) echo " NO BACKUP " ;; ... (9 Replies)
Discussion started by: rocking77
9 Replies

10. Shell Programming and Scripting

Use while loop to read file and use ${file} for both filename input into awk and as string to print

I have files named with different prefixes. From each I want to extract the first line containing a specific string, and then print that line along with the prefix. I've tried to do this with a while loop, but instead of printing the prefix I print the first line of the file twice. Files:... (3 Replies)
Discussion started by: pathunkathunk
3 Replies
SHCOMP(1)						       Korn shell utilities							 SHCOMP(1)

NAME
shcomp - compile a shell script SYNOPSIS
shcomp [ options ] [infile [outfile]] DESCRIPTION
Unless -D is specified, shcomp takes a shell script, infile, and creates a binary format file, outfile, that ksh can read and execute with the same effect as the original script. Since aliases are processed as the script is read, alias definitions whose value requires variable expansion will not work correctly. If -D is specified, all double quoted strings that are preceded by $ are output. These are the messages that need to be translated to locale specific versions for internationalization. If outfile is omitted, then the results will be written to standard output. If infile is also omitted, the shell script will be read from standard input. OPTIONS
[D dictionary] Generate a list of strings that need to be placed in a message catalog for internationalization. [n noexec] Displays warn- ing messages for obsolete or non-conforming constructs. [v verbose] Displays input from infile onto standard error as it reads it. EXIT STATUS
0 Successful completion. >0 An error occurred. SEE ALSO
ksh(1) IMPLEMENTATION
version shcomp (AT&T Research) 2003-03-02 author David Korn <dgk@research.att.com> copyright Copyright (c) 1982-2010 AT&T Intellectual Property license http://www.opensource.org/licenses/cpl1.0.txt 2003-03-02 SHCOMP(1)
All times are GMT -4. The time now is 06:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy