how to extract data from numbered files using linux in the numerical order-


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to extract data from numbered files using linux in the numerical order-
# 1  
Old 06-20-2012
Lightbulb how to extract data from numbered files using linux in the numerical order-

Hi experts,


I have a list of files containing forces as the only number as follows.
Code:
Force1.txt Force2.txt Force3.txt Force4.txt  Force5.txt . . . . . .  . . . Force100.txt

I want to put all the data(only a number ) in these forces files in the file with the same order like 1,2,3 ..100 . However , when I use the following command to arrange them in the single file.
Code:
sed -n '/^[0-9.]*$/w Result.txt' Force*.k

I mean the input from above files is listed in output file in the following order-
Code:
Force1.txt Force10.txt Force2.txt Force3.txt Force4.txt  Force5.txt . . . . . .  . . . Force99.txt

The problem is that the linux collects the data with this command in an order and not according to the precedence in number. Any suggestion for this?
best regards,
# 2  
Old 06-20-2012
i m not clear but like this ?
only numbers ?
Code:
# echo `ls -1|sed 's/File\([0-9][0-9]*\)\..*/\1/'`
100 10 11 12 13 14 15 16 17 18 19 1 20 21 22 23 24 25 26 27 28 29 2 30 31 32 33 34 35 36 37 38 39 3 40 
41 42 43 44 45 46 47 48 49 4 50 51 52 53 54 55 56 57 58 59 5 60 61 62 63 64 65 66 67 68 69 6 70 71 72 73 74 75 76 77
 78 79 7 80 81 82 83 84 85 86 87 88 89 8 90 91 92 93 94 95 96 97 98 99 9

# 3  
Old 06-20-2012
Code:
for x in Force*.txt; do x=${x%.txt}; x=${x//[a-zA-Z]/}; echo $x >> newfile ; done

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

rename numbered files to numbered files with leading zeroes

Hi, I have some hundreds/thousands of files named logX.dat, where X can be any integer, and they are sequential, X ranges between 1 and any number: log1.dat log2.dat log3.dat log6.dat log10.dat ... log6000.dat I would like to rename them to scatter_params_0001.dat... (6 Replies)
Discussion started by: pau
6 Replies

2. UNIX for Dummies Questions & Answers

How to sort a column based on numerical ascending order if it includes e-10?

I have a column of numbers in the following format: 1.722e-05 2.018e-05 2.548e-05 2.747e-05 7.897e-05 4.016e-05 4.613e-05 4.613e-05 5.151e-05 5.151e-05 5.151e-05 6.1e-05 6.254e-05 7.04e-05 7.12e-05 7.12e-05 (6 Replies)
Discussion started by: evelibertine
6 Replies

3. Programming

Sorting a vector of strings into numerical order.

I have a vector of strings that contain a list of channels like this: 101,99,22HD,432,300HD I have tried using the sort routine like this: sort(mychans.begin(),mychans.end()); For some reason my channels are not being sorted at all. I was hoping someone might have some input that might... (2 Replies)
Discussion started by: sepoto
2 Replies

4. UNIX for Dummies Questions & Answers

moving/copying files in a numerical order

Hi I am newbie to unix scripting, but i have enough knowledge to understand. I have a specific questions like, I use to collect like 3500 files per experiment, each one named like data_001.img.. data_002.img data_003.img .... data_3500.img I would like to move every 12 files in the 3500... (3 Replies)
Discussion started by: wpat
3 Replies

5. Shell Programming and Scripting

How to extract data from indexed files (ISAM files) maintained in an unix server.

Hi, Could someone please assist on a quick way of How to extract data from indexed files (ISAM files) maintained in an UNIX(AIX) server.The file data needs to be extracted in flat text file or CSV or excel format . Usually we have programs in microfocus COBOL to extract data, but would like... (2 Replies)
Discussion started by: devina
2 Replies

6. UNIX for Dummies Questions & Answers

Moving files out of multiple directories and renaming them in numerical order

Hi, I have 500 directories each with multiple data files inside them. The names are sort of random. For example, one directory has files named e_1.dat, e_5.dat, e_8.dat, etc. I need to move the files to a single directory and rename them all in numerical order, from 1.dat to 1000(or some... (1 Reply)
Discussion started by: renthead720
1 Replies

7. Shell Programming and Scripting

extract numbered line from file

This is a simple question but couldn't figure out. I have a list of numbers stored in file1: 2 3 5 and wanted to extract these numbered lines from file2: a b c d e f with output: (7 Replies)
Discussion started by: Zoho
7 Replies

8. Programming

Adding files of numerical data

Hi I was hoping that maybe someone could help me with a small piece of C code. I have a number of files, which are all of similar layout ie. three lines of text and 5-6 columns of numerical data. I need to add each of the elements of the second column in one file to their counterparts in the second... (17 Replies)
Discussion started by: Boucho
17 Replies

9. Shell Programming and Scripting

Listing files in numerical order

Hi, I'm trying to write a ksh script to copy a specified number of files from one directory to another. The files are named in the convention <switchname>_log.<num> and the numbers are sequential single digit onwards. I figured I could find some parameter for ls which would list the files in... (3 Replies)
Discussion started by: Steve_H
3 Replies
Login or Register to Ask a Question