LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-25-2013, 01:07 PM   #1
Uzer
LQ Newbie
 
Registered: Jul 2013
Posts: 1

Rep: Reputation: Disabled
awk command and loops


Hello,
I am dealing with the following problem: I am using a software for physics calculations and I use as input for this program a certain .txt file (which I open with emacs). The file contains a series of numbers put in columns. I want to change the element which is found in the 2nd row and in the second column by 0,001 and save this file under the name ("POS") in order to run again the program with "POS" as input file. I want to do this action for 100 steps and it is very tiring to do by hand....
What can I do in the terminal to command this algorithm? so far i found foreach and awk command helpful but i don't know how to use them.
Thank you in advance
 
Old 07-25-2013, 01:20 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
Sorry, but your text description really isn't detailed enough. Could you please post a short example of the input text (or a reasonable facsimile) and the desired output you want from it?

Also be sure to tell us if there's anything unusual about your environment, such as if you're on a non-linux system.
 
Old 07-25-2013, 01:26 PM   #3
sryzdn
Member
 
Registered: Feb 2013
Posts: 248

Rep: Reputation: 1
Quote:
Originally Posted by Uzer View Post
Hello,
I am dealing with the following problem: I am using a software for physics calculations
what's the name of the physics code?
 
Old 07-25-2013, 02:36 PM   #4
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,471

Rep: Reputation: 444Reputation: 444Reputation: 444Reputation: 444Reputation: 444
Quote:
Originally Posted by Uzer View Post
Hello,
I am dealing with the following problem: I am using a software for physics calculations and I use as input for this program a certain .txt file (which I open with emacs). The file contains a series of numbers put in columns. I want to change the element which is found in the 2nd row and in the second column by 0,001 and save this file under the name ("POS") in order to run again the program with "POS" as input file. I want to do this action for 100 steps and it is very tiring to do by hand....
What can I do in the terminal to command this algorithm? so far i found foreach and awk command helpful but i don't know how to use them.
Thank you in advance
I'm Sorry but I don't understand what you want/need.

I'm going to try a break it up a little

Let Input be input.txt
Let Output be POS-001.txt
LoopStart
from Input
send line 1 to Output
Line 2 , field 2 .. add (or subtract?) 0.001 ( assuming , was typo )
send new line 2 to POS.txt
send rest of lines to POS.txt

for further 99 times
Let Input be Output
Let Output be Output+1 ( POS-002.txt )

Repeat Loop


It would help greatly if you provide a sample Input and Output ( 1 and 2 ) ( say 10 lines, or 11 including header )
Do you only want to operate on Line2 ( assuming line 1 is header ), or All Lines
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Find command issues over while loop or for loops balakrishnay Linux - General 8 05-06-2013 09:19 PM
awk loops and deleting lines skray Programming 5 06-08-2009 12:58 PM
About awk command incomingid Linux - Newbie 5 04-01-2009 11:44 PM
awk command toaravind Linux - General 5 07-02-2008 02:25 AM
shell command using awk fields inside awk one71 Programming 6 06-26-2008 05:11 PM


All times are GMT -5. The time now is 09:47 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration