06-18-2009
copying from line N1 to line N2 of a file in a series of files
Dear community,
I'm quite a newbie with scripting, I have this problem:
I have a file with many lines and I want to copy the lines from 1 to N to file.1, from N+1 to 2N to file.2, and so on up to the end of the file
I have tried with something like this (N=43 in this example):
awk '{for (i=1;i<=1000;i++) if ((NR>=$i*43 -42)&&(NR<=$i*43)) print $0}' big_file >> file.$
but it doesn't output anything, neither does the following:
for ((i=1;i<=1000;i++))
do
awk '{ if ((NR>=$i*43 -42)&&(NR<=$i*43)) print $0}' big_file >> file.$
done
I've tried other ways, they all failed... do you have any suggestion?
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Can any one please help me to copy file content between particualr line numbers. (3 Replies)
Discussion started by: engineer
3 Replies
2. Shell Programming and Scripting
Hello all
i know it is pretty hard one but you will manage it all
after noticing and calculating i find a rhythm for the file i want to edit
to copy the last 12 characters in line but the problem is to add after first 25 characters in same line
in other way too copy the last 12 characters... (10 Replies)
Discussion started by: princesasa
10 Replies
3. Shell Programming and Scripting
So, I want to read line-by-line a text file with unknown number of files....
So:
a=1
b=1
while ; do
b=`sed -n '$ap' test`
a=`expr $a + 1`
$here do something with b etc
done
the problem is that sed does not seem to recognise the $a, even when trying
sed -n ' $a p'
So, I cannot read... (3 Replies)
Discussion started by: hakermania
3 Replies
4. Shell Programming and Scripting
Hi Guys,
the command ":yy" copies the line but it can be pasted in the same file. How can it be done if I want to copy it in other file. (2 Replies)
Discussion started by: ajincoep
2 Replies
5. Shell Programming and Scripting
Hi All,
I need to copy a specific line from a file to another file.
lets suppose the line number 13 of a file
when I am writing the line number explicitly.. its working fine
sed -n '13p' afile > anotherfile
but, when inside a script, i am getting the line number value inside a variable... (4 Replies)
Discussion started by: gotamp
4 Replies
6. Shell Programming and Scripting
Hi All,
I'm trying to figure out which are the trusted-ips and which are not using a script file.. I have a file named 'ip-list.txt' which contains some ip addresses and another file named 'trusted-ip-list.txt' which also contains some ip addresses. I want to read a line from... (4 Replies)
Discussion started by: mjavalkar
4 Replies
7. Shell Programming and Scripting
Hello,
I need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line... An example of entries in the file would be:
SRVXPAPI001 ERRO JUN24 07:28:34 1775
REASON= 0000, PROCID= #E506 #1065: TPCIPPR, INDEX= 003F
... (8 Replies)
Discussion started by: Ferocci
8 Replies
8. Shell Programming and Scripting
I am trying to make my script as simple as a possible but, I am not sure if the way I am approaching is necessarily the most efficient or effective it can be. What I am mainly trying to fix is a for loop to remove a string from the specified files and within this loop I am trying to copy the lines... (2 Replies)
Discussion started by: Allie_gastrator
2 Replies
9. Shell Programming and Scripting
Hello,
I would like to copy the first and third char on each line of a file and place them in the 14h and 17th char positions. The file name is listed first and is 6 char's and the dir name is second and also same char size on each line.
The file has thousands of lines.
Initial... (6 Replies)
Discussion started by: dmm
6 Replies
10. Shell Programming and Scripting
I am looking for help in processing of those options: '-n' or '-p'
I understand what they do and how to use them.
But, I would like to use them with more than one file (and without any shell-loop; loading the 'perl' once.)
I did try it and -n works on 2 files.
Question is:
- is it possible to... (6 Replies)
Discussion started by: alex_5161
6 Replies
LEARN ABOUT DEBIAN
file2sdr
FILE2SDR(1) ICI executables FILE2SDR(1)
NAME
file2sdr - SDR data ingestion test program
SYNOPSIS
file2sdr configFlags fileName
DESCRIPTION
file2sdr stress-tests SDR data ingestion by repeatedly writing all text lines of the file named fileName to one of a series of non-volatile
linked lists created in a test SDR data store named "testsdrconfigFlags". By incorporating the data store configuration into the name
(e.g., "testsdr14") we make it relatively easy to perform comparative testing on SDR data stores that are identical aside from their
configuration settings.
The operation of file2sdr is cyclical: a new linked list is created each time the program finishes copying the file's text lines and starts
over again. If you use ^C to terminate file2sdr and then restart it, the program resumes operation at the point where it left off.
After writing each line to the current linked list, file2sdr gives a semaphore to indicate that the list is now non-empty. This is mainly
for the benefit of the complementary test program sdr2file(1).
At the end of each cycle file2sdr appends a final EOF line to the current linked list, containing the text "*** End of the file ***", and
prints a brief performance report:
Processing I<lineCount> lines per second.
EXIT STATUS
0 file2sdr has terminated.
FILES
No configuration files are needed.
ENVIRONMENT
No environment variables apply.
DIAGNOSTICS
Diagnostic messages produced by file2sdr are written to the ION log file ion.log.
Can't use sdr.
ION system error. Check for earlier diagnostic messages describing the cause of the error; correct problem and rerun.
Can't create semaphore.
ION system error. Check for earlier diagnostic messages describing the cause of the error; correct problem and rerun.
SDR transaction failed.
ION system error. Check for earlier diagnostic messages describing the cause of the error; correct problem and rerun.
Can't open input file
Operating system error. Check errtext, correct problem, and rerun.
Can't reopen input file
Operating system error. Check errtext, correct problem, and rerun.
Can't read from input file
Operating system error. Check errtext, correct problem, and rerun.
BUGS
Report bugs to <ion-bugs@korgano.eecs.ohiou.edu>
SEE ALSO
sdr2file(1), sdr(3)
perl v5.14.2 2012-05-25 FILE2SDR(1)