collect data from another file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting collect data from another file
# 1  
Old 11-21-2007
collect data from another file

Hi Friends ,
I am urgently needed your help.
could you pleas help me in creating the shell script.

Requirement :
collect the data from no_file.txt

no_file.txt
============
1
11
265
290
300
313
326
351

Then create another shele script like
my_shell.csh
===========
head -11 M2_Sales_N01.txt |tail -10 >M2_Sales_N01_01.txt
head -265 M2_Sales_N01.txt |tail -254>M2_Sales_N01_02.txt
head -290 M2_Sales_N01.txt |tail -25 >M2_Sales_N01_03.txt
head -300 M2_Sales_N01.txt |tail -10 >M2_Sales_N01_04.txt

head -313 M2_Sales_N01.txt |tail -13 >M2_Sales_N01_05.txt
head -326 M2_Sales_N01.txt |tail -13 >M2_Sales_N01_06.txt
head -351 M2_Sales_N01.txt |tail -25 >M2_Sales_N01_07.txt
....
....

Logic
=====
fetch the first two digit (1,11) then last-first, 11-1 =10
head -11 M2_Sales_N01.txt |tail -10 >M2_Sales_N01_01.txt

fetch next two nos (265,11) .Then 265-11=254
head -265 M2_Sales_N01.txt |tail -254>M2_Sales_N01_02.txt

Thanks In advance.
Bikas
# 2  
Old 11-21-2007
awk

Hi folk,

THis one is ok for you.

code:
Code:
awk 'BEGIN { 
format="head -%d M2_Sales_N01.txt |tail -%d >M2_Sales_N01_%02d.txt\n"
n=0
m=0
}
{
if (n==0)
{
	tmp=$1
	n=1
}
else
{
	res=$1-tmp
	tmp=$1
	m=m+1
	printf(format,$1,res,m)
}
}' filename

# 3  
Old 11-22-2007
Wait, is this homework? Check out the FAQ, as it is heavily discouraged (item #6).
# 4  
Old 11-22-2007
Thanks a loooooooooooooooooooooooooooooot summer_cherry.

You are a gem of gems.
you have done a great help to me..


Thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. SuSE

How to filter SYSLOG data to collect meaningful information only?

Dear users, SUSE 10 sp3 and SUSE 11. I made configuration changes in '/etc/syslog-ng/syslog-ng.conf' to move SYSLOG content to LogRhythm. This is what I changed in the file. Un-comment out the following lines #Enable this and admop IP to send log messages to... (10 Replies)
Discussion started by: JDBA
10 Replies

2. Shell Programming and Scripting

Not able ot collect perldoc output to a file

I need the output of perldoc command collected to a file # perldoc -l File::Scan::ClamAV > /usr/src/asas.txt No documentation found for "File::Scan::ClamAV". # cat /usr/src/asas.txt # (2 Replies)
Discussion started by: anil510
2 Replies

3. Shell Programming and Scripting

Collect last 2 days data from /var/log/messages

I need to collect last 2 days data from /var/log/messages into a separate file (file format: flmessagetimedaymonth). I have collect today's month, date, time information in separate variable. Please help me in this issue (Probably need awk and grep function). month=$(date|awk '{print $2}')... (4 Replies)
Discussion started by: makauser
4 Replies

4. Shell Programming and Scripting

Use PYTHON to collect data weather and print in new file

Hi all, i have a task to do with Python and because i'm a beginner on it i would like your help on this. Create a python script that: Every hour collect the Temperature (e.g. 29C) and Current Condition (e.g. Clear) from this website wunderground.com/global/stations/54511.html Create a CSV... (0 Replies)
Discussion started by: ragaga123
0 Replies

5. Shell Programming and Scripting

Korn script to access multiple host and collect data

Hi, I'm newbie in Korn scripting as well as in Unix. I need to have a script to do the following. 1) ssh multiple hosts -In my case, login credentials are not an issue as all keys authorized by default. Example of host IP (24.35.14.6, 24.35.14.7, 24.35.14.8, 24.35.14.9, ... (2 Replies)
Discussion started by: blinkingdan
2 Replies

6. UNIX Desktop Questions & Answers

collect data from files

there are 200 files named file1_0.pdb,file1_60.pdb etc....it looks like: ATOM 1 N VAL 1 8.897 -21.545 -7.276 1.00 0.00 ATOM 2 H1 VAL 1 9.692 -22.015 -6.868 1.00 0.00 ATOM 3 H2 VAL 1 9.228 -20.766 -7.827 1.00 0.00 ATOM 4 H3 ... (5 Replies)
Discussion started by: kanikasharma
5 Replies

7. Shell Programming and Scripting

grep PID and collect data ?

I have a file current.csv file 2011/05/06 11:12:20 | 16:guest pid=014782 opened Boards 0, 1, 2, 3 2011/05/06 12:23:13 | 16:guest pid=014782 closed 2011/05/06 12:26:05 | 17:guest pid=022383 opened Boards 0, 1, 2, 3 2011/05/06 20:09:04 | 17:guest pid=022383 closed 2011/05/06... (5 Replies)
Discussion started by: sabercats
5 Replies

8. Shell Programming and Scripting

How to collect count of a column from log file??

Hi All, I have an Output from a log file which is something like as follows.. ***** CDR and SDR Statistics**** Wed Feb 25 00:05:00 EST 2009 *********CDR and SDR QUEUE STATUS***** Queue busy wait msgs cdr 2 2 4 sdr ... (3 Replies)
Discussion started by: nirmal84
3 Replies

9. UNIX for Dummies Questions & Answers

Enable a shell to collect data from unix, return to windows

hi I am very new to UNIX. I need to retrieve data from a unix system and store it and display as output on a windows system. Initiation of procedure is through JAVASCRIPT-based buttons on a HTML page. This should cause a set of commands to run which colllect data from a unix based server and... (1 Reply)
Discussion started by: rossalyn_maxter
1 Replies

10. Shell Programming and Scripting

ccall database and collect data from one table

I want to connect to one database and collect data from any table using shell script. (0 Replies)
Discussion started by: rinku
0 Replies
Login or Register to Ask a Question