Sponsored Content
Top Forums Shell Programming and Scripting Script to create a text file whose content is the text of another files Post 302611417 by tenteyu on Thursday 22nd of March 2012 08:04:19 PM
Old 03-22-2012
Script to create a text file whose content is the text of another files

Hello everyone,

I work under Ubuntu 11.10 (c-shell)

I need a script to create a new text file whose content is the text of another text files that are in the directory $DIRMAIL at this moment.

I will show you an example:
- On the one hand, there is a directory $DIRMAIL where there are the following files at this moment:

First file = 1332348161.2848_1.lab0_2,
Second file = 1332348161.2848_11.lab0_2,ST
Third file = 1332355415.3771_47.lab0_2
Fourth file = 1332404735.3771_53.lab0_2,

as you can see, each file always includes the word "lab" and for example its content is plaintext such as:

1332348161.2848_1.lab0_2,
first file's text
1332348161.2848_11.lab0_2,ST
second file's text
1332355415.3771_47.lab0_2,
third file's text
1332404735.3771_53.lab0_2,
fourth file's text

- What I am trying to achieve is a script to create a new file called Inbox in another directory $DIRINBOX, whose content would be the result of adding the text of each file, I mean, the following text in this case:

Inbox
first file's text
second file's text
third file's text
fourth file's text


- On the other hand, after creating Inbox file in this way, I need all the files included in $DIRMAIL.

Probably it may be a very easy script but I am a beginner and don't know how to do it. Any suggestion please


Thanks in advanced.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

create a text file in a script

Hi, i want to create a text file (init${x}.ora) and write information to it via a korn shell script. Is it right to do it as shown below (the file doesnt exist yet)? x=$1 file="$ORC/dbs/init${x}.ora" echo "info here..." >> $file will this file get created? (2 Replies)
Discussion started by: n8575
2 Replies

2. Shell Programming and Scripting

Create multiple text file from a single text file on AIX

Hi I need to create multiple text files from onc text file on AIX. The data of text files is as below: ********************************************** ********************************************** DBVERIFY: Release 10.2.0.4.0 - Production on Tue Nov 10 13:45:42 2009 Copyright (c) 1982,... (11 Replies)
Discussion started by: lodhi1978
11 Replies

3. UNIX for Dummies Questions & Answers

Script to create text file.

Hi all Below this is my script..I want to write the command to create a text file in my script below. If anyone know how to do...show me the result.I also want to do this script run automatically without type in terminal. Thanks. #!/usr/bin/sh... (6 Replies)
Discussion started by: mastercar
6 Replies

4. Shell Programming and Scripting

Need help in writing a script to create a new text file with specific data from existing two files

Hi, I have two text files. Need to create a third text file extracting specific data from first two existing files.. Text File 1: Format contains: SQL*Loader: Release 10.2.0.1.0 - Production on Wed Aug 4 21:06:34 2010 some text ............so on...and somwhere text like: Record 1:... (1 Reply)
Discussion started by: shashi143ibm
1 Replies

5. UNIX for Dummies Questions & Answers

creating text file with content from script

hi, can somebody tell me how I can create a text file with content from Bash script. The file should be prefilled with information such as current date and time then leaving the user ability to input more data right below those prefilled content. thank you :) (0 Replies)
Discussion started by: s3270226
0 Replies

6. Shell Programming and Scripting

Need to build Shell Script to search content of a text file into a folder consist several files

Have to read one file say sourcefile containing several words and having another folder containing several files. Now read the first word of Sourcefile & search it into the folder consisting sevral files, and create another file with result. We hhave to pick the filename of the file in which... (3 Replies)
Discussion started by: mukesh.baranwal
3 Replies

7. Shell Programming and Scripting

While or For with looping contructs? to create files from contents of a text file

Hi so far I created this script: vi loop.beta.sh for i in `cat extract.filenames.tabc` do echo $i done>$i === This is the original text file. $ more tabc.txt -rwx------- 1 alice staff 1586 2010-11-05 02:27 request-key .conf -rwx------- 1 ted staff 126 ... (3 Replies)
Discussion started by: wolf@=NK
3 Replies

8. Shell Programming and Scripting

Create users from a text file by script

Hi All, I am new to scripting, i want to create one script in which i can add users from a text file, assign them a default password like 123456. It should be like: Username= $i (it should take users from text file one by one) Password : 123456(default for every user) (1 Reply)
Discussion started by: prad_rocxx
1 Replies

9. UNIX for Dummies Questions & Answers

How to sort a content of a text file using a shell script?

I am new to shell scripting. I am interested how to know how to sort a content of a file using shell scripting. I've attached the 'Input file' and the 'expected output' to this thread. Details provided in the expected output file will provide details on how the sort needs to be done. ... (16 Replies)
Discussion started by: nkarthik_mnnit
16 Replies

10. Shell Programming and Scripting

Splitting a text file into smaller files with awk, how to create a different name for each new file

Hello, I have some large text files that look like, putrescine Mrv1583 01041713302D 6 5 0 0 0 0 999 V2000 2.0928 -0.2063 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0 5.6650 0.2063 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0 3.5217 ... (3 Replies)
Discussion started by: LMHmedchem
3 Replies
BUNDLE(1)						      General Commands Manual							 BUNDLE(1)

NAME
bundle - collect files for distribution SYNOPSIS
bundle file ... DESCRIPTION
Bundle writes on its standard output a shell script for rc(1) or a Bourne shell which, when executed, will recreate the original files. Its main use is for distributing small numbers of text files by mail(1). Although less refined than standard archives from ar(1) or tar(1), a bundle file is self-documenting and complete; little preparation is required on the receiving machine. EXAMPLES
bundle mkfile *.[ch] | mail kremvax!boris Send a makefile to Boris together with related and files. Upon receiving the mail, Boris may save the file sans postmark, say in gift/horse, then do cd gift; rc horse; mk SOURCE
/rc/bin/bundle SEE ALSO
ar(1), tar(1), mail(1) BUGS
Bundle will not create directories and is unsatisfactory for non-text files. Beware of gift horses. BUNDLE(1)
All times are GMT -4. The time now is 04:13 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy