LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-08-2008, 03:31 PM   #16
tostay2003
Member
 
Registered: Jun 2006
Posts: 126

Original Poster
Rep: Reputation: 15

Quote:
Originally Posted by colucix View Post
Sorry, but I don't follow you anymore. What are you trying to achieve? Where this variable comes from? Is it created in a shell script or something? Can you provide a real example?

Does this match what you're trying to do?
Code:
#!/bin/bash
var1=Field1,Field2,Field3
var2=$(echo $var1 | awk -F, '{for (i=1; i<=NF-1; i++) printf "%s, ","FRNT_" $i "_END"; printf "%s","FRNT_" $NF "_END"}')
echo $var2
You are right, this is what I am looking for

But without using other variable (just for my interest). The result should be in the same variable. Just like you have done with the file
 
Old 08-09-2008, 01:41 AM   #17
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Quote:
Originally Posted by tostay2003 View Post
You are right, this is what I am looking for

But without using other variable (just for my interest). The result should be in the same variable. Just like you have done with the file
Don't you think you can assign a variable using the same name to update its value?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
awk question on handling *.CSV "text fields" in awk jschiwal Programming 8 05-27-2010 06:23 AM
shell command using awk fields inside awk one71 Programming 6 06-26-2008 04:11 PM
AWK - why fields go to seperate lines? korhan Linux - Newbie 2 03-01-2007 03:21 PM
Supressing Fields w/ AWK Rv5 Programming 3 10-19-2004 11:06 AM
search for specific text in fields using awk Helene Programming 2 04-23-2004 12:13 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration