Have a list of numbers, want to write code to manipulate them


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Have a list of numbers, want to write code to manipulate them
# 8  
Old 01-06-2012
Hello evelibertine,

It depends on your search path for where commands/programs/scripts are. There is a variable $PATH that holdds this. If you don't feel comfortable adjusting this, then a quick way round it is (assuming that you wrote the script in the current location) to just use:
Code:
./myscript inputfile.txt > outputfile.txt

This says to execute the one in the current location. If it fails with an error that it cannot execute or permission denied type thingy, then:
Code:
chmod 755 myscript

.... and try again.

Let us know how you get on.



Cheers,
Robin
Liverpool/Blackburn
UK

Last edited by rbatte1; 01-06-2012 at 05:53 AM.. Reason: Emboldened the $PATH variable label
# 9  
Old 01-06-2012
Code:
 
$ awk '{print 100-$1}' test.txt 
95
96
85
35
68

---------- Post updated at 03:26 PM ---------- Previous update was at 03:25 PM ----------

test.txt is your input file
# 10  
Old 01-06-2012
Quote:
Originally Posted by evelibertine
I copied and pasted the script into a text file called myscript.
maybe you can try saving your file in .sh extension then try to execute with sh
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Filter and delete numbers in a list

Hello, I've got a list of a single column numbers like 3000.66 3002.55 3062.23 3242.12 etc... I would like to delete all numbers higher than for example 3060.00 and lower than 2990.00 How can I do that? Thanks in advance (2 Replies)
Discussion started by: Board27
2 Replies

2. Shell Programming and Scripting

Comparing a list of numbers is less than a variable

Hello everyone, I want to compare a list of numbers in the file TEST01 to the variable $Post. Also remove any duplicate numbers. Create an if then statement indicating if the numbers listed in TEST01 is less than the number value of $Post then print an error message. Here is the contents of... (5 Replies)
Discussion started by: seekryts15
5 Replies

3. Shell Programming and Scripting

How search a list of numbers from a file

Hi Guys! I have two input files. I want to search each of the numbers (studentid) on inputfile1 from inputfile2 and print the studentid and section that are listed from inputfile1. See the desired output below. inputfile1.txt: studentid 261054689 266605695 269826642 264966513... (2 Replies)
Discussion started by: pinpe
2 Replies

4. UNIX for Dummies Questions & Answers

List-to-Range of Numbers

Hello, I have two columns with data that look like this: Col1 Col2 ------ ----- a 1 a 2 a 3 a 4 a 7 a 8 a 9 a 10 a 11 b 6 b 7 b 8 b 9 b 14 (5 Replies)
Discussion started by: Gussifinknottle
5 Replies

5. UNIX for Dummies Questions & Answers

Getting unique list of numbers using grep

Hi, I am going to fetch a list of numbers that starts with "0032" from a file with a format like the given below: " 0032459999 0032458888 0032457777 0032451111 0032452222 0032453333 0032459999 0032458888 0032457777 0032451111 0032452222 0032453333 " I want to get a unique... (6 Replies)
Discussion started by: tinku
6 Replies

6. Shell Programming and Scripting

adding a list of numbers 3 by 3

i have a list of numbers like this; 124 235 764 782 765 451 983 909 ... and i want to make a sum with the first 3 of them then the next 3 and so on. 124+235+764=1123 782+765+451=1998 ... some ideas? (4 Replies)
Discussion started by: Tártaro
4 Replies

7. Shell Programming and Scripting

how to write a script contain list of questions

hi i want to write a script that contain questions upto 50..when i run the script it has to ask the questions one by one with options like a,b,c,d and user has to answer the each question and finally result (contain how many user selected correctly) please help me...i need hints to do....... (8 Replies)
Discussion started by: srinivas2828
8 Replies

8. Shell Programming and Scripting

Add a list of numbers

I need to add a list of numbers contained in a file. For example, the file would look like this: 10 290 342 5409 I need to get a total sum of all the numbers in the list. Any ideas? Thanks! (2 Replies)
Discussion started by: TheCrunge
2 Replies
Login or Register to Ask a Question