Sponsored Content
Top Forums Shell Programming and Scripting Concatenating awk fields with variable Post 302851459 by sniper57 on Monday 9th of September 2013 04:20:48 AM
Old 09-09-2013
Concatenating awk fields with variable

Hi,

I am trying to do this:-
Code:
FILE=application.log
PID=12345

FILE=`echo $FILE | awk -F "." '{print $1 "$PID" $2}'`

echo $FILE
application$PIDlog

I need the output to be application12345.log but I am not sure how to get the $PID variable into the output. I have tried various things but not getting very far!

Any help appreciated!

Many thanks
Simon

Last edited by vbe; 09-09-2013 at 05:32 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

concatenating string and variable

how to concatenate a string and variable like a=rahul and i want to put it into another variable 'b' as "rahul_prasath" i dont want to use another variable for "_prasath" how to do it? (1 Reply)
Discussion started by: rolex.mp
1 Replies

2. Shell Programming and Scripting

awk sed cut? to rearrange random number of fields into 3 fields

I'm working on formatting some attendance data to meet a vendors requirements to upload to their system. With some help on the forums here, I have the data close. But they've since changed what they want. The vendor wants me to submit three fields to them. Field 1 is the studentid field,... (4 Replies)
Discussion started by: axo959
4 Replies

3. Shell Programming and Scripting

Concatenating lines ending with '+' using awk

Hi, I have an ASCII text file where some of the lines are ending with '+' character. I have to concatenate the next successive line with those lines having the trailing '+' char by removing that char. The below awk code has some problems to do this task: awk '{while(sub(/\+$/,"")) {... (12 Replies)
Discussion started by: royalibrahim
12 Replies

4. Shell Programming and Scripting

awk print variable then fields in variable

i have this variable: varT="1--2--3--5" i want to use awk to print field 3 from this variable. i dont want to do the "echo $varT". but here's my awk code: awk -v valA="$varT" "BEGIN {print valA}" this prints the entire line. i feel like i'm so close to getting what i want. i... (4 Replies)
Discussion started by: SkySmart
4 Replies

5. Shell Programming and Scripting

How to print 1st field and last 2 fields together and the rest of the fields after it using awk?

Hi experts, I need to print the first field first then last two fields should come next and then i need to print rest of the fields. Input : a1,abc,jsd,fhf,fkk,b1,b2 a2,acb,dfg,ghj,b3,c4 a3,djf,wdjg,fkg,dff,ggk,d4,d5 Expected output: a1,b1,b2,abc,jsd,fhf,fkk... (6 Replies)
Discussion started by: 100bees
6 Replies

6. Shell Programming and Scripting

awk - compare 1st 15 fields of record with 20 fields

I'm trying to compare 2 files for differences in a selct number of fields. When differnces are found it will write the whole record of the second file including appending '|C' out to a delta file. Each record will have 20 fields, but only want to do comparison of 1st 15 fields. The 1st field of... (7 Replies)
Discussion started by: sljnk
7 Replies

7. Shell Programming and Scripting

awk processing of variable number of fields data file

Hy! I need to post-process some data files which have variable (and periodic) number of fields. For example, I need to square (data -> data*data) the folowing data file: -5.34281E-28 -3.69822E-29 8.19128E-29 9.55444E-29 8.16494E-29 6.23125E-29 4.42106E-29 2.94592E-29 1.84841E-29 ... (5 Replies)
Discussion started by: radudownload
5 Replies

8. Shell Programming and Scripting

awk sort based on difference of fields and print all fields

Hi I have a file as below <field1> <field2> <field3> ... <field_num1> <field_num2> Trying to sort based on difference of <field_num1> and <field_num2> in desceding order and print all fields. I tried this and it doesn't sort on the difference field .. Appreciate your help. cat... (9 Replies)
Discussion started by: newstart
9 Replies

9. Shell Programming and Scripting

Concatenating(??) shell variable with string

Dear Users, I am writing a for loop in shell (BASH), and am struggling with a very specific detail: SU_DATA=/home/........./su/ for(blah blah blah) { a=1001 b=1002 suop2 $SU_DATA/$a_clean.su $SU_DATA/$b_clean.su op=sum > W1.su } Here, it looks like the variables are... (1 Reply)
Discussion started by: martm
1 Replies

10. UNIX for Beginners Questions & Answers

Awk: subset of fields as variable with sprint

Dear Unix Gurus, input: A|1|2|3|4|5 B|1|2|3|4|3 C|1|2|3|4|1 D|1|9|3|4|12 output: A_(5);B(3);C(1)|1|2|3|4 D_(12)|1|9|3|4 Details: If $2, $3, $3, $5 are identical, concatenate $1 and associated $NF together in the first field. But I am trying to do the above by passing the identical... (6 Replies)
Discussion started by: beca123456
6 Replies
madwimax(8)															       madwimax(8)

NAME
madwimax - driver for mobile WiMAX equipment based on Samsung CMC-730 SYNOPSIS
madwimax [OPTIONS] DESCRIPTION
madwimax is an experimental reverse-engineered linux driver for mobile WiMAX (802.16e) devices based on Samsung CMC-730 chip. These devices are currently supported: o Samsung SWC-U200 o Samsung SWC-E100 o Samsung SWM-S10R (it is built in Samsung NC-10 netbook) The driver is completely user-space. It requires libusb-1.0 and TUN/TAP driver to work. OPTIONS
-d, --daemonize Daemonize after startup. --device=VID:PID Specify the USB device by VID:PID combination. -e FILE, --event-script=FILE Specify path to the event script. --exact-device=BUS/DEVICE Specify the exact USB BUS/DEVICE (use with care!). -f, --detach-dvd Detach pseudo-DVD kernel driver on startup. -h, --help Display help. -l FILE, --log-file=FILE Write log to the specified FILE instead of the other methods. -o, --diode-off Turn off the diode (diode is turned on by default). -q, --quiet Switch off logging. -V, --version Print the program version number. -v, --verbose Increase the log level. --ssid=SSID Specify service set identifier, or SSID, which is a friendly name that identifies a particular 802.16e wireless network. EXIT STATUS
0 Success 1 Failure (syntax or usage error; hardware error; underlying software error; unexpected error). BUGS
See the madwimax issue tracker: <http://code.google.com/p/madwimax/issues/list> AUTHOR
Written by Alexander Gordeev, <mailto:lasaine@lvk.cs.msu.su> RESOURCES
Main web site: <http://code.google.com/p/madwimax/> COPYING
Copyright (C) 2008-2009 Alexander Gordeev. Free use of this software is granted under the terms of the GNU General Public License (GPL). 27 September 2009 madwimax(8)
All times are GMT -4. The time now is 10:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy