Sponsored Content
Full Discussion: How to separate file content
Top Forums UNIX for Dummies Questions & Answers How to separate file content Post 302225467 by runmeat6 on Friday 15th of August 2008 12:47:25 PM
Old 08-15-2008
Quote:
Originally Posted by shamrock
If all the fields were in double ticks then just printing the even fields would work...but looks like the code, location and address fields are separated by four or more spaces??
Code:
awk -F" {4,}" '{printf("%s\n%s\n%s\n\n", $1, $2, $3)}' file

I do not believe awk will accept a range (e.g. "{4,}") because that was what I originally tried. In fact I believe awk will only accept zero or more ("*") or one or more ("+") and no matter what string you send to the FS variable with the -F option it appears to go in a set ("[ ]") string, because the four spaces followed by a + that Rubin championed earlier did not appear to work after all in tests on my system except to separate any spaced text.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To read and separate number and words in file and store to two new file using shell

hi, I am a begginer in unix and i want to know how to open a file and read it and separate the numbers & words and storing it in separate files, Using shell scripting. Please help me out for this. Regards S.Kamakshi (2 Replies)
Discussion started by: kamakshi s
2 Replies

2. UNIX for Dummies Questions & Answers

creating separate directories according to file extension and keeping file in different directory as

unix program to which a directory name will be passed as parameter. This directory will contain files with various extensions. This script will create directories with the names of the extention of the files and then put the files in the corresponding folder. All files which do not have any... (2 Replies)
Discussion started by: Deekay.p
2 Replies

3. Shell Programming and Scripting

How to split a data file into separate files with the file names depending upon a column's value?

Hi, I have a data file xyz.dat similar to the one given below, 2345|98|809||x|969|0 2345|98|809||y|0|537 2345|97|809||x|544|0 2345|97|809||y|0|651 9685|98|809||x|321|0 9685|98|809||y|0|357 9685|98|709||x|687|0 9685|98|709||y|0|234 2315|98|809||x|564|0 2315|98|809||y|0|537... (2 Replies)
Discussion started by: nithins007
2 Replies

4. Shell Programming and Scripting

Separate lines in csv by column content (newbie)

Hello everyone I have a csv file organized just like in the following example: col1,col2,col3,CODE_0, ... , colN col1,col2,col3,CODE_0, ... , colN col1,col2,col3,CODE_1, ... , colN col1,col2,col3,CODE_1, ... , colN col1,col2,col3,CODE_1, ... , colN col1,col2,col3,CODE_2, ... , colN... (7 Replies)
Discussion started by: yomaya
7 Replies

5. Shell Programming and Scripting

Compare large file and identify difference in separate file

I have a very large system generated file containing around 500K rows size 100MB like following HOME|ALICE STREET|3||NEW LISTING HOME|NEWPORT STREET|1||NEW LISTING HOME|KING STREET|5||NEW LISTING HOME|WINSOME AVENUE|4||MODIFICATION CAR|TOYOTA|4||NEW LISTING CAR|FORD|4||NEW... (9 Replies)
Discussion started by: jubaier
9 Replies

6. Shell Programming and Scripting

Compare two string in two separate file and delete some line of file

Hi all i want to write program with shell script that able compare two file content and if one of lines of file have # at the first of string or nothing find same string in one of two file . remove the line in second file that have not the string in first file. for example: file... (2 Replies)
Discussion started by: saleh67
2 Replies

7. Shell Programming and Scripting

Sed: replace content from file with the content from file

Hi, I am having trouble while using 'sed' with reading files. Please help. I have 3 files. File A, file B and file C. I want to find content of file B in file A and replace it by content in file C. Thanks a lot!! Here is a sample of my question. e.g. (file A: a.txt; file B: b.txt; file... (3 Replies)
Discussion started by: dirkaulo
3 Replies

8. Shell Programming and Scripting

How to grep a log file for words listed in separate text file?

Hello, I want to grep a log ("server.log") for words in a separate file ("white-list.txt") and generate a separate log file containing each line that uses a word from the "white-list.txt" file. Putting that in bullet points: Search through "server.log" for lines that contain any word... (15 Replies)
Discussion started by: nbsparks
15 Replies

9. Shell Programming and Scripting

How to remove exisiting file content from a file and have to append new file content?

hi all, i had the below script x=`cat input.txt |wc -1` awk 'NR>1 && NR<'$x' ' input.txt > output.txt by using above script i am able to remove the head and tail part from the input file and able to append the output to the output.txt but if i run it for second time the output is... (2 Replies)
Discussion started by: hemanthsaikumar
2 Replies

10. Programming

creating separate output file for each input file in python

Experts, Need your help for this. Please support My motive is to create seperate output file for each Input Files(File 1 and File2) in another folder say(/tmp/finaloutput) Input files File 1(1.1.1.1.csv) a,b,c 43,17104773,3 45,17104234,4 File 2(2.2.2.2.csv) a,b,c 43,17104773,1... (2 Replies)
Discussion started by: as7951
2 Replies
Template::Toolkit(3pm)					User Contributed Perl Documentation				    Template::Toolkit(3pm)

NAME
Template::Toolkit - Template Processing System Introduction The Template Toolkit is a collection of Perl modules which implement a fast, flexible, powerful and extensible template processing system. It is "input-agnostic" and can be used equally well for processing any kind of text documents: HTML, XML, CSS, Javascript, Perl code, plain text, and so on. However, it is most often used for generating static and dynamic web content, so that's what we'll focus on here. Although the Template Toolkit is written in Perl, you don't need to be a Perl programmer to use it. It was designed to allow non- programmers to easily create and maintain template-based web sites without having to mess around writing Perl code or going crazy with cut- n-paste. However, the Template Toolkit is also designed to be extremely flexible and extensible. If you are a Perl programmer, or know someone who is, then you can easily hook the Template Toolkit into your existing code, data, databases and web applications. Furthermore, you can easily extend the Template Toolkit through the use of its plugin mechanism and other developer APIs. Whatever context you use it in, the primary purpose of the Template Toolkit is to allow you to create a clear separation between the presentation elements of your web site and everything else. If you're generating static web pages, then you can use it to separate the commonly repeated user interface elements on each page (headers, menus, footers, etc.) from the core content. If you're generating dynamic web pages for the front end of a web application, then you'll also be using it to keep the back-end Perl code entirely separate from the front-end HTML templates. Either way, a clear separation of concerns is what allow you to concentrate on one thing at a time without the other things getting in your way. And that's what the Template Toolkit is all about. Documentation The documentation for the Template Toolkit is organised into five sections. The Template::Manual contains detailed information about using the Template Toolkit. It gives examples of its use and includes a full reference of the template language, configuration options, filters, plugins and other component parts. The Template::Modules page lists the Perl modules that comprise the Template Toolkit. It gives a brief explanation of what each of them does, and provides a link to the complete documentation for each module for further information. If you're a Perl programmer looking to use the Template Toolkit from your Perl programs then this section is likely to be of interest. Most, if not all of the information you need to call the Template Toolkit from Perl is in the documentation for the Template module. You only really need to start thinking about the other modules if you want to extend or modify the Template Toolkit in some way, or if you're interested in looking under the hood to see how it all works. The documentation for each module is embedded as POD in each module, so you can always use "perldoc" from the command line to read a module's documentation. e.g. $ perldoc Template $ perldoc Template::Context ...etc... It's worth noting that all the other documentation, including the user manual is available as POD. e.g. $ perldoc Template::Manual $ perldoc Template::Manual::Config ...etc... The Template::Tools section contains the documentation for Template::Tools::tpage and Template::Tools::ttree. These are two command line programs that are distributed with the Template Toolkit. tpage is used to process a single template file, ttree for processing entire directories of template files. The Template::Tutorial section contains two introductory tutorials on using the Template Toolkit. The first is Template::Tutorial::Web on generating web content. The second is Template::Tutorial::Datafile on using the Template Toolkit to generate other data formats including XML. The final section of the manual is Template::FAQ which contains answers to some of the Frequently Asked Questions about the Template Toolkit. You can read the documentation in HTML format either online at the Template Toolkit web site, http://template-toolkit.org/ <http://template-toolkit.org/>, or by downloading the HTML version of the documentation from http://template-toolkit.org/download/index.html#html_docs <http://template-toolkit.org/download/index.html#html_docs> and unpacking it on your local machine. Author The Template Toolkit was written by Andy Wardley (<http://wardley.org/> <mailto:abw@wardley.org>) with assistance and contributions from a great number of people. Please see Template::Manual::Credits for a full list. Copyright Copyright (C) 1996-2008 Andy Wardley. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See Also Template, Template::Manual, Template::Modules, Template::Tools, Template::Tutorial perl v5.14.2 2011-12-20 Template::Toolkit(3pm)
All times are GMT -4. The time now is 09:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy