04-07-2008
Dividing single file by lines?
Hi,
I have a situation where I need to append specific lines to a series of files only when specific lines are found. I can do this using sed -f, however because of the byte limitation for a sedscr file, I create multiple sedscr files (of 180 lines each due to the length of the strings) and do multiple passes. Sometimes I only do 5 passes, sometimes as many as 13.
As an example, each of these is 180 lines (except the last which has any remaining lines):
sedscr_1_of_11:
/string 1/a\
string 2
I've been doing this manually, but am now charged with creating a menu for another (non-technical) business area to execute. My problem is after I create one massive sedscr file (from a single input file), I don't know how to divvy up that single sedscr file into multiple 180-line files.
Any insight would be greatly appreciated.
Last edited by anoc; 04-07-2008 at 09:47 PM..
Reason: correction
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Greetings,
I have a file: hostnames.txt which has -
# cat hostnames.txt
machine1
machine2
I need the output to be saved to a variable as:
HOSTNAMELIST=machine1,machine2
Please advise.
Thanks,
Chiru (3 Replies)
Discussion started by: chiru_h
3 Replies
2. Shell Programming and Scripting
Hi Gurus,
I am a starter with shell script. Help me to achieve this. I have a file with lines given below.
line1
line2
line3
.
.
etc
How can I arrange the file which should look like
line1,line2,line3,..,..,etc
Any help on this is appreciated. (9 Replies)
Discussion started by: smv
9 Replies
3. Shell Programming and Scripting
Let's assume that I have a file name called ‘A' and it has 100 lines in it and would like to split these 100 lines into 4 files as specified bellow.
INPUT: Input file name A
1
2
3
4
5
6
7
8
9
........100
Output: 4 output files (x,y,z,w)
File x should contains (Skip 4 lines)... (15 Replies)
Discussion started by: subbarao25
15 Replies
4. Shell Programming and Scripting
Hi,
I have a requirement with,
No~Dt~Notes
1~2011/08/1~"aaa
bbb
ccc
ddd
eee
fff
ggg
hhh"
Single column alone got splitted into multiple lines.
I require the output as
No~Dt~Notes
1~2011/08/1~"aaa<>bbb<>ccc<>ddd<>eee<>fff<>ggg<>hhh"
mean to say those new lines to be... (1 Reply)
Discussion started by: Bhuvaneswari
1 Replies
5. Shell Programming and Scripting
My question is
I am finding the new.txt file in the directory
I am finding current.txt file in the directory in 2nd time
I am finding fallback.txt in the directory in 3rd time
all with find command
now my question is
let suppose I got all threee files in one directory then I want... (2 Replies)
Discussion started by: anuragpgtgerman
2 Replies
6. Shell Programming and Scripting
I have a file proc.txt:
if @debug = 1 then
message 'Start Processing ', @procname, dateformat(now(*), 'hh:mm:ss'), @julian type info to client;
end if;
/*
execute immediate with quotes
'insert into sys_suppdata (property, value, key_name)
location ''' || @supp_server || '.' ||... (5 Replies)
Discussion started by: kidncute
5 Replies
7. Shell Programming and Scripting
Hi,
I have a file like mentioned below..For each specific id starting with > I want to join the sequence in multiple lines to a single line..Is there a simple way in awk or sed to do this
>ENST00000558922 cdna:KNOWN
TCCAGGATCCAGCCTCCCGATCACCGCGCTAGTCCTCGCCCTGCCTGGGCTTCCCCAGAG... (2 Replies)
Discussion started by: Diya123
2 Replies
8. Shell Programming and Scripting
Hi
Am confused with the usage of "sed" command
I want to replace a single line with multiple lines of a file..
eg.,
A file has
Hi, How are you?
I need to replace as
Am fine
What are You doing?
I used the script as
string1="Hi, How are you?"
echo "$string1 is the value"... (4 Replies)
Discussion started by: Priya Amaresh
4 Replies
9. UNIX for Dummies Questions & Answers
Hi,
I need help!
I have two files, one containing a list of codes and the other a list of codes and their meaning. I need to extract from file 2 all the codes from file 1 into a new file.
These are my files:
File1:
Metbo
Metbo
Memar
Mth
Metbo
File2:
Metbo Methanoculleus... (3 Replies)
Discussion started by: Lokaps
3 Replies
10. Shell Programming and Scripting
Hi all,
I need help to parse this xml file that has paragraphs broken in different lines and I would like to join in a single line.
I hope you can understand my explanation. Thanks for any help/direction.
The script could be in bash, awk, ruby, perl whatever please
In the output I want:... (8 Replies)
Discussion started by: Ophiuchus
8 Replies
GREP(1) General Commands Manual GREP(1)
NAME
grep - search a file for lines containing a given pattern
SYNOPSIS
grep [-elnsv] pattern [file] ...
OPTIONS
-e -e pattern is the same as pattern
-c Print a count of lines matched
-i Ignore case
-l Print file names, no lines
-n Print line numbers
-s Status only, no printed output
-v Select lines that do not match
EXAMPLES
grep mouse file # Find lines in file containing mouse
grep [0-9] file # Print lines containing a digit
DESCRIPTION
Grep searches one or more files (by default, stdin) and selects out all the lines that match the pattern. All the regular expressions
accepted by ed and mined are allowed. In addition, + can be used instead of * to mean 1 or more occurrences, ? can be used to mean 0 or 1
occurrences, and | can be used between two regular expressions to mean either one of them. Parentheses can be used for grouping. If a
match is found, exit status 0 is returned. If no match is found, exit status 1 is returned. If an error is detected, exit status 2 is
returned.
SEE ALSO
cgrep(1), fgrep(1), sed(1), awk(9).
GREP(1)