Sponsored Content
Full Discussion: awk with echo list
Top Forums Shell Programming and Scripting awk with echo list Post 303045812 by bmk123 on Tuesday 14th of April 2020 03:06:34 AM
Old 04-14-2020
awk with echo list

Hi Team,

we have one oracle function return like this and assign to value like this.

Code:
col_list={print $64,$64,$52,$64,$64,$33}
tail -n +"${record_pstn}" "${file_name}" |/usr/bin/awk -f <( echo "${col_list}" ) FS="${ifs}" OFS="${ofs}"

while running the script using ./test.sh it working fine.
suppose we run like sh test.sh and it is raising the below error.

Error :syntax error near unexpected token `('

please help me.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

echo is too slow. HELP with Awk

Hello All, Below is a simple script i worte to find the 208th char in a file. If the char = "C" then I re-direct the line to a file called change.txt. If it is not "C" then I re-direct it to a file called delete.txt. My problem is I have a file 0f 500K lines. this script is very slow. I am... (4 Replies)
Discussion started by: eja
4 Replies

2. Shell Programming and Scripting

awk to echo ???

Hi All, I have the below command. awk 'BEGIN {printf("%1s","cat")}' > temp.txt can i do the same using echo ?If So, how? Thanks JS (2 Replies)
Discussion started by: jisha
2 Replies

3. Shell Programming and Scripting

Using echo in AWK

Hello, I have written the script below to extract specific data from a text file and then use the data extracted as parameters for another shell script call 'loto_tsim'. Everytime I run my script it complains about the 'echo' line. Am I missing something? I have spent hours and still cannot solve... (10 Replies)
Discussion started by: jermaine4ever
10 Replies

4. Shell Programming and Scripting

perform echo and awk inside a string

hi, just wanted to make a shortcut of this one a="a b c" b=`echo $a | awk '{print $2}'` echo "the middle is $b" why can't i do this: a="a b c" echo "the middle is ${`echo $a | awk '{print $2}'`}" <- bad substitution :wall: thanks (6 Replies)
Discussion started by: h0ujun
6 Replies

5. Shell Programming and Scripting

Improve performance of echo |awk

Hi, I have a script which looks like this. Input file data1^20 data2^30 #!/bin/sh file"/home/Test.txt" while read line do echo $line |awk 'BEGIN { FS = "^" } ; { print $2 }' echo $line |awk 'BEGIN { FS = "^" } ; { print $1 }' | gzip | wc -c done <"$file" How can i... (4 Replies)
Discussion started by: chetan.c
4 Replies

6. Shell Programming and Scripting

Problem with writing to output - awk, echo

Hello all, I wrote this command line for some calculation on my given input files based on another input file which is a txt file. while read BAM REGION; do samtools view $BAM $REGION | awk '{if ($2==0) print $0}' | wc -l >>log.txt; echo "$REGION"; done >> log.txt <regions.txt It takes... (4 Replies)
Discussion started by: @man
4 Replies

7. Shell Programming and Scripting

Combining echo and awk

i have a script that has many lines similar to: echo $var | awk -F"--" '{print $2}' as you can see, two commands are being run here. echo and awk. id like to combine this into one awk statement. i tried: awk -F"--" "BEGIN{print $var; print $2}" but i get error messages. (10 Replies)
Discussion started by: SkySmart
10 Replies

8. Shell Programming and Scripting

Echo awk output from its variable

Stumped with the formatting of the awk output when used with variables, e.g.: awk -F, 'BEGIN {OFS=","} print {$2,$3,$4}' $infile1 produces the desired output (with rows), but when echoing the variable below, the output is one continuous line var1=$(awk -F, 'BEGIN {OFS=","} print... (4 Replies)
Discussion started by: ux4me
4 Replies

9. UNIX for Beginners Questions & Answers

Need to save output of echo and awk to a file

Hi, I am generating a YAML file from a hosts file, but am having trouble saving it to a new file. hosts file 127.0.0.1 localhost 192.168.1.2 host1 192.168.1.3 host2 192.168.1.4 host3 192.168.1.5 host4 YAML file $ echo 'host_entries:' && awk '{printf " %s:\n ip:... (3 Replies)
Discussion started by: sand1234
3 Replies
tail(1) 							   User Commands							   tail(1)

NAME
tail - deliver the last part of a file SYNOPSIS
/usr/bin/tail [+-s number [lbcr]] [file] /usr/bin/tail [-lbcr] [file] /usr/bin/tail [+- number [lbcf]] [file] /usr/bin/tail [-lbcf] [file] /usr/xpg4/bin/tail [-f | -r] [-c number | -n number] [file] /usr/xpg4/bin/tail [+- number [l | b | c] [f]] [file] /usr/xpg4/bin/tail [+- number [l] [f | r]] [file] DESCRIPTION
The tail utility copies the named file to the standard output beginning at a designated place. If no file is named, the standard input is used. Copying begins at a point in the file indicated by the -cnumber, -nnumber, or +-number options (if +number is specified, begins at distance number from the beginning; if -number is specified, from the end of the input; if number is NULL, the value 10 is assumed). number is counted in units of lines or byte according to the -c or -n options, or lines, blocks, or bytes, according to the appended option l, b, or c. When no units are specified, counting is by lines. OPTIONS
The following options are supported for both /usr/bin/tail and /usr/xpg4/bin/tail. The -r and -f options are mutually exclusive. If both are specified on the command line, the -f option is ignored. -b Units of blocks. -c Units of bytes. -f Follow. If the input-file is not a pipe, the program does not terminate after the line of the input-file has been copied, but enters an endless loop, wherein it sleeps for a second and then attempts to read and copy further records from the input-file. Thus it can be used to monitor the growth of a file that is being written by some other process. -l Units of lines. -r Reverse. Copies lines from the specified starting point in the file in reverse order. The default for r is to print the entire file in reverse order. /usr/xpg4/bin/tail The following options are supported for /usr/xpg4/bin/tail only: -c number The number option-argument must be a decimal integer whose sign affects the location in the file, measured in bytes, to begin the copying: + Copying starts relative to the beginning of the file. - Copying starts relative to the end of the file. none Copying starts relative to the end of the file. The origin for counting is 1; that is, -c+1 represents the first byte of the file, -c-1 the last. -n number Equivalent to -cnumber, except the starting location in the file is measured in lines instead of bytes. The origin for count- ing is 1. That is, -n+1 represents the first line of the file, -n-1 the last. OPERANDS
The following operand is supported: file A path name of an input file. If no file operands are specified, the standard input is used. USAGE
See largefile(5) for the description of the behavior of tail when encountering files greater than or equal to 2 Gbyte ( 2^31 bytes). EXAMPLES
Example 1 Using the tail Command The following command prints the last ten lines of the file fred, followed by any lines that are appended to fred between the time tail is initiated and killed. example% tail -f fred The next command prints the last 15 bytes of the file fred, followed by any lines that are appended to fred between the time tail is initi- ated and killed: example% tail -15cf fred ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of tail: LANG, LC_ALL, LC_CTYPE, LC_MES- SAGES, and NLSPATH. EXIT STATUS
The following exit values are returned: 0 Successful completion. >0 An error occurred. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: /usr/bin/tail +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |CSI |Enabled | +-----------------------------+-----------------------------+ /usr/xpg4/bin/tail +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWxcu4 | +-----------------------------+-----------------------------+ |CSI |Enabled | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ SEE ALSO
cat(1), head(1), more(1), pg(1), dd(1M), attributes(5), environ(5), largefile(5), standards(5) NOTES
Piped tails relative to the end of the file are stored in a buffer, and thus are limited in length. Various kinds of anomalous behavior can happen with character special files. SunOS 5.11 13 Jul 2005 tail(1)
All times are GMT -4. The time now is 06:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy