Sponsored Content
Top Forums UNIX for Dummies Questions & Answers using nawk to concate the fields Post 302161560 by raychu65 on Friday 25th of January 2008 04:02:24 AM
Old 01-25-2008
Power using nawk to concate the fields

I have the the following question:

# cat report.lis | nawk -F: '{ if($0 ~ "^BE NO:") print "report_"$2".lis"}' Smilie
.lisrt_ 111
.lisrt_ 111
.lisrt_ 222
.lisrt_ 222
.lisrt_ 333
.lisrt_ 333

# cat report.lis | nawk -F: '{ if($0 ~ "^BE NO:") print "report_" $2}'
report_ 111
report_ 111
report_ 222
report_ 222
report_ 333
report_ 333

My question why I cannot concate these 3 fields: "report_" $2 ".lis"
expected result is:
report_ 111.lis
report_ 111.lis
report_ 222.lis
report_ 222.lis
report_ 333.lis
report_ 333.lis

By the way, I am using Sun server for unix script.

Please help and thanks..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Concate all lines into one.

I have a file with 1000 records and I have to produce another file with 1 line which is a concatentation of all these records. Please help. (1 Reply)
Discussion started by: oracle8
1 Replies

2. Shell Programming and Scripting

Append tabs at the end of each line in NAWK -- varying fields

Hi, I need some help in knowing how I can append tabs at the end of each line... The data looks something like this: field1, field2, field3, field4 1 2 3 4 5 I have values in field1 and field 2 in the first row and I would like to append tab on field3 and field4 for the first row..and in... (6 Replies)
Discussion started by: madhunk
6 Replies

3. Shell Programming and Scripting

concate the record

how i can bring this file into three records in my sample text file there are thre records new records always start with Data File ================================================== samle file ================================================= Data File:... (7 Replies)
Discussion started by: aboorkuma
7 Replies

4. Shell Programming and Scripting

I need help counting the fields and field separators using Nawk

I need help counting the fields and field separators using Nawk. I have a file that has multiple lines on it and I need to read the file 1 at a time and then count the fields and field separators and then store those numbers in variables. I then need to delete the first 5 fields and the blank... (3 Replies)
Discussion started by: scrappycc
3 Replies

5. Shell Programming and Scripting

String concate problem

Hello there, I am facing the following problem in string concate. I am returning a sql column value to a shell script variable . Now when I am trying to concate the variable with another string (string appears first) I am getting a space between the two concate. Example p is the shell... (2 Replies)
Discussion started by: Pratik4891
2 Replies

6. Shell Programming and Scripting

nawk -- separation of records on basis of number of fields

A file file1.txt exists having records like The delimiter being "|" X|_|Y|_|Z|_| (number of fields 7) A|_|B|_| (number of fields 5) X|_|Z|_|H|_| (number of fields 7) A|_|D|_|S|_| (number of... (4 Replies)
Discussion started by: centurion_13
4 Replies

7. Shell Programming and Scripting

awk /nawk :: print the everything except the first and the last fields

format of file1 "file1.txt" 1 2 3 4 A B C XX YY ZZ AA WWW The output must contain except the first and last column the output must be 2 3 B YY ZZ AA (8 Replies)
Discussion started by: centurion_13
8 Replies

8. Shell Programming and Scripting

Counting Multiple Fields with awk/nawk

I am trying to figure out a way in nawk to 1) get a count of the number of times a value appears in field 1 and 2) count each time the same value appears in field 2 for each value of field 1. So for example, if I have a text file with the following: grapes, purple apples, green squash, yellow... (2 Replies)
Discussion started by: he204035
2 Replies

9. Shell Programming and Scripting

Concate a string in awk

Hello Community, i have a litte Problem with concating a string in an awk command. val_arr=( $( cat myfile | awk ' NR==1 { name=$2} NR==3 { dateformat=$9 OFS $6 OFS $8 OFS $7 OFS $10} NR==4 { length=$8} NR==5 { progress=int($3) } END{print name,dateformat,length,progress}; ... (6 Replies)
Discussion started by: demonking
6 Replies

10. UNIX for Advanced & Expert Users

Nawk coding trying to compare two fields in a file

I have a file. We can call file1. It has these contents. STOPLOSS Control_file 0000000010.000 STOPLOSS Audit_file_Signoff +0000000010.00 nawk '{ fmt="%3s %15s %15s %15s %21s\n"; if ($3==$6) { tpy="Successful Match"; jnme=$1;... (4 Replies)
Discussion started by: wawa
4 Replies
Config::Model::models::LCDd(3pm)			User Contributed Perl Documentation			  Config::Model::models::LCDd(3pm)

NAME
Config::Model::models::LCDd - Configuration class LCDd VERSION
version 2.021 DESCRIPTION
Configuration classes used by Config::Model LCDd.conf -- configuration file for the LCDproc server daemon LCDd This file contains the configuration for the LCDd server. The format is ini-file-like. It is divided into sections that start at markers that look like [section]. Comments are all line-based comments, and are lines that start with ' The server has a 'central' section named [server]. For the menu there is a section called [menu]. Further each driver has a section which defines how the driver acts. The drivers are activated by specifying them in a driver= line in the server section, like: Driver=curses This tells LCDd to use the curses driver. The first driver that is loaded and is capable of output defines the size of the display. The default driver to use is curses. If the driver is specified using the -d <driver> command line option, the Driver= options in the config file are ignored. The drivers read their own options from the respective sections. Model information extracted from template /etc/LCDd.conf BUGS
This model does not support to load several drivers. Loading several drivers is probably a marginal case. Please complain to the author if this assumption is false Elements server Optional. Type node. menu Optional. Type node. bayrad Optional. Type warped_node. CFontz Optional. Type warped_node. CFontzPacket Optional. Type warped_node. curses Optional. Type warped_node. CwLnx Optional. Type warped_node. ea65 Optional. Type warped_node. EyeboxOne Optional. Type warped_node. g15 Optional. Type warped_node. glcd Optional. Type warped_node. glcdlib Optional. Type warped_node. glk Optional. Type warped_node. hd44780 Optional. Type warped_node. icp_a106 Optional. Type warped_node. IOWarrior Optional. Type warped_node. imon Optional. Type warped_node. imonlcd Optional. Type warped_node. IrMan Optional. Type warped_node. irtrans Optional. Type warped_node. joy Optional. Type warped_node. lb216 Optional. Type warped_node. lcdm001 Optional. Type warped_node. lcterm Optional. Type warped_node. lirc Optional. Type warped_node. lis Optional. Type warped_node. MD8800 Optional. Type warped_node. mdm166a Optional. Type warped_node. ms6931 Optional. Type warped_node. mtc_s16209x Optional. Type warped_node. MtxOrb Optional. Type warped_node. mx5000 Optional. Type warped_node. NoritakeVFD Optional. Type warped_node. picolcd Optional. Type warped_node. pyramid Optional. Type warped_node. sed1330 Optional. Type warped_node. sed1520 Optional. Type warped_node. serialPOS Optional. Type warped_node. serialVFD Optional. Type warped_node. shuttleVFD Optional. Type warped_node. stv5730 Optional. Type warped_node. SureElec Optional. Type warped_node. svga Optional. Type warped_node. text Optional. Type warped_node. t6963 Optional. Type warped_node. tyan Optional. Type warped_node. ula200 Optional. Type warped_node. sli Optional. Type warped_node. vlsys_m428 Optional. Type warped_node. xosd Optional. Type warped_node. SEE ALSO
o cme o Config::Model::models::LCDd::CFontz o Config::Model::models::LCDd::CFontzPacket o Config::Model::models::LCDd::CwLnx o Config::Model::models::LCDd::EyeboxOne o Config::Model::models::LCDd::IOWarrior o Config::Model::models::LCDd::IrMan o Config::Model::models::LCDd::MD8800 o Config::Model::models::LCDd::MtxOrb o Config::Model::models::LCDd::NoritakeVFD o Config::Model::models::LCDd::SureElec o Config::Model::models::LCDd::bayrad o Config::Model::models::LCDd::curses o Config::Model::models::LCDd::ea65 o Config::Model::models::LCDd::g15 o Config::Model::models::LCDd::glcd o Config::Model::models::LCDd::glcdlib o Config::Model::models::LCDd::glk o Config::Model::models::LCDd::hd44780 o Config::Model::models::LCDd::icp_a106 o Config::Model::models::LCDd::imon o Config::Model::models::LCDd::imonlcd o Config::Model::models::LCDd::irtrans o Config::Model::models::LCDd::joy o Config::Model::models::LCDd::lb216 o Config::Model::models::LCDd::lcdm001 o Config::Model::models::LCDd::lcterm o Config::Model::models::LCDd::lirc o Config::Model::models::LCDd::lis o Config::Model::models::LCDd::mdm166a o Config::Model::models::LCDd::menu o Config::Model::models::LCDd::ms6931 o Config::Model::models::LCDd::mtc_s16209x o Config::Model::models::LCDd::mx5000 o Config::Model::models::LCDd::picolcd o Config::Model::models::LCDd::pyramid o Config::Model::models::LCDd::sed1330 o Config::Model::models::LCDd::sed1520 o Config::Model::models::LCDd::serialPOS o Config::Model::models::LCDd::serialVFD o Config::Model::models::LCDd::server o Config::Model::models::LCDd::shuttleVFD o Config::Model::models::LCDd::sli o Config::Model::models::LCDd::stv5730 o Config::Model::models::LCDd::svga o Config::Model::models::LCDd::t6963 o Config::Model::models::LCDd::text o Config::Model::models::LCDd::tyan o Config::Model::models::LCDd::ula200 o Config::Model::models::LCDd::vlsys_m428 o Config::Model::models::LCDd::xosd COPYRIGHT
2011, Dominique Dumont 1999-2011, William Ferrell and others LICENSE
GPL-2 perl v5.14.2 2012-11-09 Config::Model::models::LCDd(3pm)
All times are GMT -4. The time now is 04:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy