Separating Pattern Into Separate Files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Separating Pattern Into Separate Files
# 8  
Old 09-28-2010
My shell is csh...thanks!
# 9  
Old 09-28-2010
Quote:
Originally Posted by Double-E
My shell is csh...thanks!
Sorry , i'm not able to help you in csh Smilie
# 10  
Old 09-28-2010
Ok, thank you!
# 11  
Old 09-28-2010
Just put it in a file, make it executable (chmod) and insert the following as the first line:
Code:
#!/bin/sh

then Frans' script should work..
# 12  
Old 09-28-2010
To Frans and Scrutinizer,

I can actually run bash files and when I tried that code it gave me the following error regarding line 19:

18. while read L
19. do N=$(echo $L | grep -E '^(VTZ|NYZ)[0-9]+') && { F=$N; :>$F; }
20. echo $L >> $F
21. done < infile

line 19: $F: ambiguous redirect

Thanks!
# 13  
Old 09-28-2010
What if you replace $F by ${F} ?
try adding an echo $F, just after the F=$N assignment.
# 14  
Old 09-28-2010
Thanks for the quick response, but I still got

18. while read L
19. do N=$(echo $L | grep -E '^(VTZ|NYZ)[0-9]+') && { F=$N; echo $F :>${F}; }

20. echo $L >> $F
21. done < infile

line 19: $F: ambiguous redirect (and this message appeared 23 times.

Thanks again for your help!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Solved] Pattern match and write to separate files

I need to parse a file and depending on a patern match(in the insert job line) separate files have to be created with a line added (content in file2). Mapping for pattern match and add line : for Alpha 123 for Beta 234 for Gamma 345 no match (goes into another file) File 1 ... (3 Replies)
Discussion started by: w020637
3 Replies

2. Shell Programming and Scripting

How to generate a csv files by separating the values from the input file based on position?

Hi All, I need help for doing the following. I have a input file like: aaaaaaaaaabbbbbbbbbbbbbbbbbbbb cccbbbbbaaaaaadddddaaaabbbbbbb now I am trying to generate a output csv file where i will have for e.g. 0-3 chars of each line as the first column in the csv, 4-10 chars of the line as... (3 Replies)
Discussion started by: babom
3 Replies

3. Programming

Separating two classes in two files

I have a file Map.hh shown below. I want to put the two classes Phase and Map in two different files Phase.hh and Map.hh. I have forward declaration before the Map class. How can I tackle this situation? ////////////////////////////////////////////////////////////////////////// #ifndef... (3 Replies)
Discussion started by: kristinu
3 Replies

4. Shell Programming and Scripting

Separating list of input files (*.file) with a comma in bash script

Hi all, I'm trying to get a bash script working for a program (bowtie) which takes a list of input files (*.fastq) and assembles them to an output file (outfile.sam). All the .fastq files are in one folder in my home directory (~/infiles). The problem is that the 'bowtie' requires that... (7 Replies)
Discussion started by: TuAd
7 Replies

5. Shell Programming and Scripting

Find required files by pattern in xml files and the change the pattern on Linux

Hello, I need to find all *.xml files that matched by pattern on Linux. I need to have written the file name on the screen and then change the pattern in the file just was found. For instance. I can start the script with arguments for keyword and for value, i.e script.sh keyword... (1 Reply)
Discussion started by: yart
1 Replies

6. Shell Programming and Scripting

Separating delimited file by pattern with exclusion list

I have a file with the contents below jan_t=jan;feb_t=feb;mar_t=mar;year=2010 jan_t=null;feb_t=feb;mar_t=mar;year=2010 jan_t=jan;feb_t=feb;mar_t=mar;year=2010 I want to extract out all the fields values ending with "_t" , however, i want to exclude feb_t and mar_t from the results In... (6 Replies)
Discussion started by: alienated
6 Replies

7. Shell Programming and Scripting

Merging files into a single tab delimited file with a space separating

I have a folder that contains say 50 files in a sequential order: cdf_1.txt cdf_2.txt cdf_3.txt cdf_3.txt . . . cdf_50.txt. I need to merge these files in the same order into a single tab delimited file. I used the following shell script: for x in {1..50}; do cat cdf_${x}.txt >>... (3 Replies)
Discussion started by: Lucky Ali
3 Replies

8. UNIX for Dummies Questions & Answers

Simple script for separating files

Hi all, I was wondering if someone could help me writing a simple script on separating files into separate folders. I have 92 files called various things and I want to separate these folders like so: Create a folder called "1" and put files 1-23 in it Create a folder called "2" and put... (5 Replies)
Discussion started by: hertingm
5 Replies

9. Shell Programming and Scripting

extract x lines after a pattern - place each result in separate file

Hi all, I have many files that have 1 or more occurrences of the information I want. There are two distinct sets of information. I want get this info and place each occurrence in its own file. The 3 lines before one set are this grid 00 01 02 16 17 18 **40 lines of code I want to... (5 Replies)
Discussion started by: gobi
5 Replies

10. Shell Programming and Scripting

to separate a specific pattern

Hi friends, I have a file with following pattern. OBJECT TYPE="locale", NAME=locale_nl_NL, UNIQUE_FIELD=win32_lcid FIELDS clarify_lang = 0; END_FIELDS END_OBJECT NAME=locale_nl_NL OBJECT TYPE="locale", NAME=locale_nl_BE UNIQUE_FIELD=win32_lcid FIELDS iso_cntry =... (11 Replies)
Discussion started by: shriashishpatil
11 Replies
Login or Register to Ask a Question