Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Shell Script to Read the given file contents into a merged one file Post 303034821 by Siva SQL on Tuesday 7th of May 2019 12:29:22 PM
Old 05-07-2019
Shell Script to Read the given file contents into a merged one file

Like to have shell script to Read the given file contents into a merged one file with header of path+file name followed by file contents into a single output file.

While reading and merging the file contents into a single file, Like to keep the format of the source file.

Code:
/app/oracle/build_lib/wrkfldr952.0_20150614/ddl/alter_modify_keg.sql 
/app/oracle/build_lib/wrkfldr952.0_20150614/ddl/alter_modify_kim.sql
/app/oracle/build_lib/wrkfldr952.0_20150614/ddl/client_cmpmadr1.sql 
/app/oracle/build_lib/wrkfldr952.0_20150614/ddl/client_cmpmaur1.sql 
/app/oracle/build_lib/wrkfldr952.0_20150628/ddl/alter_modify_keg.sql
 /app/oracle/build_lib/wrkfldr952.0_20150628/ddl/alter_modify_kim.sql

------ Sample Output ----
1. Reading the file# /app/oracle/build_lib/wrkfldr952.0_20150614/ddl/alter_modify_keg.sql
Code:
aaa
  aaa
aa

2. Reading the file# /app/oracle/build_lib/wrkfldr952.0_20150614/ddl/alter_modify_kim.sql
Code:
bbbbbbbbb
#sssss   tttt 523


Thanks, Siva SQL


Moderator's Comments:
Mod Comment
Please wrap all code, data/files, input & output/errors in CODE tags.
It makes it far easier to read an preserves spacing for indenting or fixed-width data.

Last edited by rbatte1; 05-08-2019 at 08:37 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

search for the contents in many file and print that file using shell script

hello have a file1 H87I Y788O T347U J23U and file2 J23U U887Y I99U T556U file3 I99O J99T F557J file4 N99I T666U R55Y file5 H87I T347U file6 H77U R556Y E44T file7 Y788O K98U H8I May be using script we can use file1 to search for all the files and have the output H87I file5... (3 Replies)
Discussion started by: cdfd123
3 Replies

2. Shell Programming and Scripting

update file contents using shell script

Hi, I am having a file which contains as below Names(aaaa ,bbbb ,cccc ,dddd) now i want the file to be updated with new value 'eeee' as below Names(aaaa ,bbbb ,cccc ,dddd ,eeee) Is there a way to script this ? Thanks, (5 Replies)
Discussion started by: drams
5 Replies

3. Shell Programming and Scripting

Shell script for converting file contents into CSV

Hi, I am new in unix, I just want to replace some values from text file according to column numbers. Like, I am having a table as given below: val1 val2 val3 val4 val5 val6 val7 val8 val9 val10 val11 val12 val13 Now i want... (5 Replies)
Discussion started by: rish_max
5 Replies

4. Shell Programming and Scripting

Need shell script to read two file at same time and print out in single file

Need shell script to read two file at same time and print output in single file Example I have two files 1) file1.txt 2) file2.txt File1.txt contains Aaa Bbb Ccc Ddd Eee Fff File2.txt contains Zzz Yyy Xxx (10 Replies)
Discussion started by: sreedhargouda
10 Replies

5. Shell Programming and Scripting

shell script to compare file contents

Hello Has anyone got an example shell script that I can use to compare the contents of two files. The files should contain the same contents, eg. file1.txt apple pear grape file2.txt apple pear grape (2 Replies)
Discussion started by: deedaz
2 Replies

6. Shell Programming and Scripting

script to read the contents of a file and print

Hi, Need help in writing a script to read the contents of this file test Test 00a 00b 00c 00d 00e 00f where it need to read each line to give a display such as form meta from dev 00a , config=Striped; add dev 00b:00f to meta 00a Can any one help me in writing this script (2 Replies)
Discussion started by: praveen1516
2 Replies

7. Shell Programming and Scripting

Replace partial contents of file with contents read from other file

Hi, I am facing issue while reading data from a file in UNIX. my requirement is to compare two files and for the text pattern matching in the 1st file, replace the contents in second file by the contents of first file from start to the end and write the contents to thrid file. i am able to... (2 Replies)
Discussion started by: seeki
2 Replies

8. Shell Programming and Scripting

Modifying contents of the file in shell script

Hello all, I have a Kconfig file that looks like something below ... ================================ menu "Application type" config GUI_TYPE_STANDARD bool "Standard Application" source "cfg/config/std.in" source... (12 Replies)
Discussion started by: anand.shah
12 Replies

9. Shell Programming and Scripting

Script for getting the file merged

Hi, I have two files separated by bars at each line File 1 : A|4356|13456|23456 A|4356|2986|98732 A|8765|218|1432567 File 2: B|12|13456|1234567 B|11|13456|123456789 B|33|2986|98732 B|11|2986|14578965 B|8765|218|147584 Common field is third field like 13456, 2986 and 218 in both... (5 Replies)
Discussion started by: Mannu2525
5 Replies

10. Shell Programming and Scripting

Shell script (sh file) logic to compare contents of one file with another file and output to file

Shell script logic Hi I have 2 input files like with file 1 content as (file1) "BRGTEST-242" a.txt "BRGTEST-240" a.txt "BRGTEST-219" e.txt File 2 contents as fle(2) "BRGTEST-244" a.txt "BRGTEST-244" b.txt "BRGTEST-231" c.txt "BRGTEST-231" d.txt "BRGTEST-221" e.txt I want to get... (22 Replies)
Discussion started by: pottic
22 Replies
SCRIPT(1)						    BSD General Commands Manual 						 SCRIPT(1)

NAME
script -- make typescript of terminal session SYNOPSIS
script [-a] [-c COMMAND] [-f] [-q] [-t] [file] DESCRIPTION
Script makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1). If the argument file is given, script saves all dialogue in file. If no file name is given, the typescript is saved in the file typescript. Options: -a Append the output to file or typescript, retaining the prior contents. -c COMMAND Run the COMMAND rather than an interactive shell. This makes it easy for a script to capture the output of a program that behaves differently when its stdout is not a tty. -f Flush output after each write. This is nice for telecooperation: One person does `mkfifo foo; script -f foo' and another can super- vise real-time what is being done using `cat foo'. -q Be quiet. -t Output timing data to standard error. This data contains two fields, separated by a space. The first field indicates how much time elapsed since the previous output. The second field indicates how many characters were output this time. This information can be used to replay typescripts with realistic typing and output delays. The script ends when the forked shell exits (a control-D to exit the Bourne shell (sh(1)), and exit, logout or control-d (if ignoreeof is not set) for the C-shell, csh(1)). Certain interactive commands, such as vi(1), create garbage in the typescript file. Script works best with commands that do not manipulate the screen, the results are meant to emulate a hardcopy terminal. ENVIRONMENT
The following environment variable is utilized by script: SHELL If the variable SHELL exists, the shell forked by script will be that shell. If SHELL is not set, the Bourne shell is assumed. (Most shells set this variable automatically). SEE ALSO
csh(1) (for the history mechanism), scriptreplay(1). HISTORY
The script command appeared in 3.0BSD. BUGS
Script places everything in the log file, including linefeeds and backspaces. This is not what the naive user expects. AVAILABILITY
The script command is part of the util-linux-ng package and is available from ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/. Linux July 30, 2000 Linux
All times are GMT -4. The time now is 03:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy