Sponsored Content
Top Forums Shell Programming and Scripting append "awk command" to the end of each line Post 302475888 by gc_sw on Tuesday 30th of November 2010 08:13:48 AM
Old 11-30-2010
Data append "awk command" to the end of each line

hi;
this is my qqq.mos:
Code:
l ./gcsw 86.0.0.1 'lt all;l+;lset SectorPort=860 Tilt 861;l-'
l ./gcsw 86.0.0.2 'lt all;l+;lset SectorPort=862 Tilt 863;l-'
l ./gcsw 86.0.0.3 'lt all;l+;lset SectorPort=864 Tilt 865;l-'
...


i want to append;
Code:
l nawk 'NR==14 && $NF!="Set."{print "l ./gcsw "r" '"'"'lt all;"p"'"'"'"} NR==5{r=$2} NR==3{p=$2 FS $3 FS $4 FS $5}' $logfile > /home/gcsw/again.mos

to the end of each line and i want to see:
Code:
l ./gcsw 86.0.0.1 'lt all;l+;lset SectorPort=860 Tilt 861;l-;l nawk 'NR==14 && $NF!="Set."{print "l ./gcsw "r" '"'"'lt all;"p"'"'"'"} NR==5{r=$2} NR==3{p=$2 FS $3 FS $4 FS $5}' $logfile > /home/gcsw/again.mos'
l ./gcsw 86.0.0.2 'lt all;l+;lset SectorPort=862 Tilt 863;l-;l nawk 'NR==14 && $NF!="Set."{print "l ./gcsw "r" '"'"'lt all;"p"'"'"'"} NR==5{r=$2} NR==3{p=$2 FS $3 FS $4 FS $5}' $logfile > /home/gcsw/again.mos'
l ./gcsw 86.0.0.3 'lt all;l+;lset SectorPort=864 Tilt 865;l-;l nawk 'NR==14 && $NF!="Set."{print "l ./gcsw "r" '"'"'lt all;"p"'"'"'"} NR==5{r=$2} NR==3{p=$2 FS $3 FS $4 FS $5}' $logfile > /home/gcsw/again.mos'
...

it is hard to write to a file an awk code. i am using:
Code:
l nawk -v q="'" 'BEGIN{d="\""; printf "%s\n","l nawk "q"NR==14 && $NF!="d"Set."d"{print "d"l ./gcsw "d"r"d" "q d q d q"lt all;"d"p"d q d q d q d"} NR==5{r=$2} NR==3{p=$2 FS $3 FS $4 FS $5}"q" $logfile > /home/gcsw/again.mos" }' > /home/gcsw/qqq.mos

to write it in single way but donot know how to append it to the end of every line. SmilieSmilieSmilieSmilie

thanks..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

extran NUll character added after end of line "\n"

Hi All, I am facing a strange situation and want to find why it is occuring . When i convert the whole line into Hexadecimal character i can find the junk value after new line (\n) . If i look in binary mode it is not visible. PLease let me know how possible the junk character is added... (1 Reply)
Discussion started by: arunkumar_mca
1 Replies

2. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

3. Shell Programming and Scripting

each line as 20digit long append zero "0" in front

i have an ip file like 121 1213412 34345353 long file want to made each line as 20digit long append zero "0" in front as 121 become 00000000000000000121 (1 Reply)
Discussion started by: RahulJoshi
1 Replies

4. Shell Programming and Scripting

sed append "\n" to end of every line in file

I know it sounds simple, but I want to e-mail the last 6 lines of a log file, which I have tailed into logresults.txt. I'm using echo -e "Subject:server results\nFrom:server log <user@domain.com>\n"`cat logresults.txt` | sendmail -t user@domain.com which works, but the body of the e-mail has... (4 Replies)
Discussion started by: unclecameron
4 Replies

5. Shell Programming and Scripting

SED or AWK "append line to the previous line"

Hi, How can I remove the line beak in the following case if the line begin with the special char “;”? TEXT Text;text ;text Text;text;text I want to convert the text to: Text;text;text Text;text;text I have already tried to use... (31 Replies)
Discussion started by: research3
31 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. Shell Programming and Scripting

AWK for multiple line records RS="^" FS="#"

I have to pull multiple line records with ^ as the record separator(RS)... # should be my field separator (FS)... Sample record is: ^-60#ORA-00060: deadlock detected while waiting for resource ORA-00001: unique constraint (SARADM.TCKNUM_PK) violated#PROC:AVAILABLE_FOR_GETNXTTIC#02/27/2012... (7 Replies)
Discussion started by: Vidhyaprakash
7 Replies

8. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

9. UNIX for Beginners Questions & Answers

Append content using "tee" command

Hi, How to append content into a file using tee command echo " file1 is archived"| tee -a archive.txt echo " file2 is archived"| tee -a archive.txt echo " file3 is archived"| tee -a archive.txt how to append content as new rows in the archive.txt Thanks, Srinadh. (4 Replies)
Discussion started by: srinadhreddy27
4 Replies

10. Shell Programming and Scripting

awk "date" and "system" command

Hello experts! I need your help please I have a file.txt of which I want to extract 3rd and 4th columns with date with the form e.g.: 2016-11-25 03:14:50and pass them to "date" command, but also append the 9th column in a file as well. So I want to execute date -d '2016-11-25 03:14:50' ... (2 Replies)
Discussion started by: phaethon
2 Replies
lset(1T)						       Tcl Built-In Commands							  lset(1T)

__________________________________________________________________________________________________________________________________________________

NAME
lset - Change an element in a list SYNOPSIS
lset varName ?index...? newValue _________________________________________________________________ DESCRIPTION
The lset command accepts a parameter, varName, which it interprets as the name of a variable containing a Tcl list. It also accepts zero or more indices into the list. The indices may be presented either consecutively on the command line, or grouped in a Tcl list and pre- sented as a single argument. Finally, it accepts a new value for an element of varName. If no indices are presented, the command takes the form: lset varName newValue or lset varName {} newValue In this case, newValue replaces the old value of the variable varName. When presented with a single index, the lset command treats the content of the varName variable as a Tcl list. It addresses the index'th element in it (0 refers to the first element of the list). When interpreting the list, lset observes the same rules concerning braces and quotes and backslashes as the Tcl command interpreter; however, variable substitution and command substitution do not occur. The command constructs a new list in which the designated element is replaced with newValue. This new list is stored in the variable varName, and is also the return value from the lset command. If index is negative or greater than or equal to the number of elements in $varName, then an error occurs. If index has the value end, it refers to the last element in the list, and end-integer refers to the last element in the list minus the specified integer offset. If additional index arguments are supplied, then each argument is used in turn to address an element within a sublist designated by the previous indexing operation, allowing the script to alter elements in sublists. The command, lset a 1 2 newValue or lset a {1 2} newValue replaces element 2 of sublist 1 with newValue. The integer appearing in each index argument must be greater than or equal to zero. The integer appearing in each index argument must be strictly less than the length of the corresponding list. In other words, the lset command cannot change the size of a list. If an index is outside the permitted range, an error is reported. EXAMPLES
In each of these examples, the initial value of x is: set x [list [list a b c] [list d e f] [list g h i]] => {a b c} {d e f} {g h i} The indicated return value also becomes the new value of x (except in the last case, which is an error which leaves the value of x unchanged.) lset x {j k l} => j k l lset x {} {j k l} => j k l lset x 0 j => j {d e f} {g h i} lset x 2 j => {a b c} {d e f} j lset x end j => {a b c} {d e f} j lset x end-1 j => {a b c} j {g h i} lset x 2 1 j => {a b c} {d e f} {g j i} lset x {2 1} j => {a b c} {d e f} {g j i} lset x {2 3} j => list index out of range In the following examples, the initial value of x is: set x [list [list [list a b] [list c d]] [list [list e f] [list g h]]] => {{a b} {c d}} {{e f} {g h}} The indicated return value also becomes the new value of x. lset x 1 1 0 j => {{a b} {c d}} {{e f} {j h}} lset x {1 1 0} j => {{a b} {c d}} {{e f} {j h}} SEE ALSO
list(1T), lappend(1T), lindex(1T), linsert(1T), llength(1T), lsearch(1T), lsort(1T), lrange(1T), lreplace(1T) KEYWORDS
element, index, list, replace, set ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +--------------------+-----------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +--------------------+-----------------+ |Availability | SUNWTcl | +--------------------+-----------------+ |Interface Stability | Uncommitted | +--------------------+-----------------+ NOTES
Source for Tcl is available on http://opensolaris.org. Tcl 8.4 lset(1T)
All times are GMT -4. The time now is 03:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy