Insert row into empty file...how?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Insert row into empty file...how?
# 8  
Old 12-12-2013
The touch command does not delete any files. It creates the file if it does not exist, or updates the modification timestamp otherwise.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Insert a value between two empty delimiter in the file.

Would like to insert value between two empty delimiter and at the very last too if empty. $ cat customerleft.tbl 300|Customer#000000300|I0fJfo60DRqQ|7|17-165-193-5964|8084.92|\N|p fluffily among the slyly express grouches. furiously express instruct||||||||||||||||||||||||\N... (3 Replies)
Discussion started by: Mannu2525
3 Replies

2. Shell Programming and Scripting

Insert newline when grep result is empty

Given a csv file with 40 columns with name, address, hometown etc. I use a bash command in 1 line which: 1. gets the address column and pipes that to 2. grep the first digit and everything that follows Command: awk -F ";" '{print $19}' /Users/jb/Desktop/ReorderTempTotal.csv | grep -o "\d.*"... (7 Replies)
Discussion started by: JBVeenstra
7 Replies

3. Shell Programming and Scripting

Insert empty columns inside a pipe delimited file

Hi All , I have pipe delimiter file with 11 columns . I need to insert 4 empty columns after column 10 . and After 11 column I need to insert a column which is having the same value for all the rows . My file 1|2|3|4|5|6|7|8|9|10|11 New file ... (11 Replies)
Discussion started by: Hypesslearner
11 Replies

4. Shell Programming and Scripting

Insert empty columns in a flat file

Hi, I have a tab delimited flat file, for example shown below Name Desg Loc a b c d e fI want to insert an empty column inbetween the column Desc and Loc, the result should be like shown below: Name LName Desg Loc a b c d e ... (6 Replies)
Discussion started by: sampoorna
6 Replies

5. Shell Programming and Scripting

sed - insert text if column empty

Hi, I want to insert the text 'Unknown' in 2 specific columns in a csv file (actually | separated) if the column is blank. Its always the same columns. I have tried using sed: sed "s/||/|Unknown|/g" but there are occasion where other fields are blank and they need to be left blank. This... (4 Replies)
Discussion started by: ksexton
4 Replies

6. Shell Programming and Scripting

insert text into empty file

I have an awk script to extract data from several files and create output in the following format as a csv file: xxxx 01/04/12 0001 0 When data is present, I have a file. When no data is available in the input files, I would still like to create a file that looks like this: xxxx... (1 Reply)
Discussion started by: banjo25
1 Replies

7. Shell Programming and Scripting

split row into lines and insert file name

I have a directory with several hundred files. The file format is a space delimited row with an unknown number of columns: A B C D E F G ... I need to turn this format File1 A File1 B File2 A File3 A File3 B File3 C ... I can use grep to display the filename next to each row of... (2 Replies)
Discussion started by: newreverie
2 Replies

8. Shell Programming and Scripting

How To Erase a line is a row is empty?

Hi! i've been reading you guys for some time, now there is something I couldn't find here, I'm trying to purge some data for my thesis but my measurements have some gaps in the third columns. The solution is simple, -Erase those lines where the third column is empty ¿How? example... (1 Reply)
Discussion started by: AriasFco
1 Replies

9. Shell Programming and Scripting

Sed insert text at first line of empty file

I can't seem to get sed to allow me to insert text in the first line of an empty file. I have a file.txt that is a 0 byte file. I want sed to insert " fooBar" onto the first line. I've tried a few options and nothing seems to work. They work just fine if there's text in the file tho. Help? (4 Replies)
Discussion started by: DC Slick
4 Replies

10. Shell Programming and Scripting

How to insert data befor some field in a row of data depending up on values in row

Hi I need to do some thing like "find and insert before that " in a file which contains many records. This will be clear with the following example. The original data record should be some thing like this 60119827 RTMS_LOCATION_CDR INSTANT_POSITION_QUERY 1236574686123083rtmssrv7 ... (8 Replies)
Discussion started by: aemunathan
8 Replies
Login or Register to Ask a Question
File::Queue(3pm)					User Contributed Perl Documentation					  File::Queue(3pm)

NAME
File::Queue - Persistent FIFO queue implemented in pure perl! SYNOPSIS
use strict; # always! use File::Queue; my $q = new File::Queue (File => '/var/spool/yourprog/queue'); $q->enq('some flat text1'); $q->enq('some flat text2'); $q->enq('some flat text3'); # Get up to first 10 elements my $contents = $q->peek(10); my $elem1 = $q->deq(); my $elem2 = $q->deq(); # empty the queue $q->reset(); DESCRIPTION
This module allows for the creation of persistent FIFO queue objects. File::Queue only handles scalars as queue elements. If you want to work with references, serialize them first! The module was written with speed in mind, and it is very fast, but it should be used with care. Please refer to the CAVEATS section. Interface File::Queue implements a OO interface. The object methods and parameters are described below. Methods File::Queue supports all of the queue-related functions a developer should expect. o new() Instantiates your File::Queue object. Parameters are described in the next sub-section. o enq() Enqueues a string element to the queue. o deq() Dequeues a string element from the queue, and returns the element. If the queue is empty, nothing is returned. o peek(n) Returns an arrayref containing the next n elements in the queue. If the queue size is less than n, all elements are returned. If the queue is empty, an empty arrayref is returned. o reset() Emptys the queue. o close() Closes the filehandles belonging to the queue object ('.dat' and '.idx'). o delete() Deletes the files belonging to the queue object ('.dat' and '.idx'). Parameters There are a number of parameters that can be passed when constructing your File::Queue objects. Parameters are case-insensitive. o File (required) File::Queue creates two files using this parameter as the base. In the case of the example in the SYNOPSIS, the two files are '/var/spool/yourprog/queue.dat' and '/var/spool/yourprog.idx'. The '.dat' file holds all of the data, the '.idx' file holds the byte index (pointer) of the starting point of the first element in the queue. o Mode (optional) The file bit mode to be shared by both the '.dat' and '.idx' files. Defaults to '0600'. o Seperator (optional) The character or byte sequence that is used to seperate queue elements in the '.dat' file. It should be something you can guarantee will NEVER appear in your queue data. Defaults to the newline character. o BlockSize (optional) This is the size of the byte chunks that are pulled at each iteration when checking for the end of a queued element. Defaults to 64, which will be fine for most cases, but can be tweaked or tuned for your specific case to squeeze out a few extra nanoseconds. CAVEATS
This module should never be used in situations where the queue is not expected to become empty. The '.dat' file is not truncated (emptied) until the queue is empty. Even the data you've already dequeued remains in the '.dat' file until the queue is empty. If you keep enqueueing elements and never FULLY dequeue everything, eventually your disk will fill up! SEE ALSO
Tie::File AUTHOR
Jason Lavold <jlavold [ at ] gmail.com> perl v5.10.0 2008-12-22 File::Queue(3pm)