Sponsored Content
Top Forums Shell Programming and Scripting Bash copy file contents into an existing file at a specific location Post 302296480 by gshepherd7 on Wednesday 11th of March 2009 07:10:19 AM
Old 03-11-2009
Bash copy file contents into an existing file at a specific location

Hi all

I need to copy the entire contents of one file into an existing file at a specific location. I know the exact line number where I need to put it. It appears I would use either sed or awk to do this, but I have been unsuccessful so far:

File A
line 1
line 2
line 3
line 4

File B
paragraph 1
paragraph 2

So I would end up with:
File A
line 1
line 2
paragraph 1
paragraph 2
line 3
line 4

Here's what I have been trying to do:

while read line
do
sed '$POSa\$line' B.txt > A.txt
done < B.txt


Thanks for the help.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reading specific contents from a file and appending it to another file

Hi, I need to write a shell script (ksh) to read contents starting at a specific location from one file and append the contents at specific location in another file. Please find below the contents of the source file that I need to read the contents from, File 1 -----# more... (5 Replies)
Discussion started by: dnicky
5 Replies

2. UNIX for Dummies Questions & Answers

excutable script to copy a file to a different location.

Hi, I'm try to create an executable file to copy a file to a different location. Help plz. Thanx. (4 Replies)
Discussion started by: nazehcalil
4 Replies

3. Shell Programming and Scripting

tail copy of a file to remote location

Hello, I have a solaris box and a windows server. The windows server runs cygwin for ssh service. I have an audit log in solaris box. When ever new records are added to the log file, this delta has to be trasported to a remote file in windows. I can do a ssh once in a while, but want the... (7 Replies)
Discussion started by: unori
7 Replies

4. UNIX for Dummies Questions & Answers

how to copy a file without remove the contents of the target file?

Hello every body, Kindly support me to "copy a file without remove the contents of the target file" Thanks in advance. :) Ahmed Amer Cairo,Egypt (2 Replies)
Discussion started by: ahmedamer12
2 Replies

5. Shell Programming and Scripting

.sh file To rename existing file and copy new file

Hi All, I am very new to shell scripting . In my current task i want to create .sh file that will rename the existing file with appending _bu in it. And then copy new file . e.g if i have file linuxFirst.java then i want to rename it to linuxFirst_bu.java ..Then want replace with latest... (1 Reply)
Discussion started by: maheshkaranjkar
1 Replies

6. Shell Programming and Scripting

How to copy a file from one location to another location?

I have file file1.txt in location 'loc1'. Now i want a copy of this file in location 'loc2' with a new file called test.txt. Please help me how to do this in shell script. (1 Reply)
Discussion started by: vel4ever
1 Replies

7. Shell Programming and Scripting

How to find a existing file location and directory location in Solaris box?

Hi This is my third past and very impressed with previous post replies Hoping the same for below query How to find a existing file location and directory location in solaris box (1 Reply)
Discussion started by: buzzme
1 Replies

8. Shell Programming and Scripting

Copy file from UNIX to shared location

Hi All, I want to transfer file from UNIX to shared locataion . Shared location doesn't resides on my system. Can somebody tell me is there any way i can transfer file from UNIX to shared location without using any tool WINSCP. Thanks, Amit (1 Reply)
Discussion started by: Amit786
1 Replies

9. Shell Programming and Scripting

Find and Copy file of specific location

Dear All, I need to transfer all files present in one location to another but those files should be of specific extension like. Find and copy all files of extension .xls, .pdf, .txt from location usr/tmp to location /per/Treat (6 Replies)
Discussion started by: yadavricky
6 Replies

10. Shell Programming and Scripting

Copy files based on specific word in a file name & its extension and putting it in required location

Hello All, Since i'm relatively new in shell script need your guidance. I'm copying files manually based on a specific word in a file name and its extension and then moving it into some destination folder. so if filename contains hyr word and it has .md and .db extension; it will move to TUM/HYR... (13 Replies)
Discussion started by: prajaktaraut
13 Replies
stripe(8)						      System Manager's Manual							 stripe(8)

NAME
stripe - Stripes a file across several volumes in a file domain SYNOPSIS
/usr/sbin/stripe -n volume_count filename OPTIONS
Specifies the number of volumes the striped file crosses. The number of volumes must be greater than one. OPERANDS
Specifies the name of the file to stripe. DESCRIPTION
The stripe utility enables you to improve the read/write performance of a file. The stripe utility directs a zero-length file (a file with no data written to it yet) to be spread evenly across several volumes within a file domain. As data is appended to the file, the data is spread across the volumes. AdvFS determines the number of pages per stripe segment and alternates the segments among the disks in a sequen- tial pattern. Existing, nonzero-length files cannot be striped using the stripe utility. To stripe an existing file, create a new file, use the stripe utility to stripe the new file, and copy the contents of the file you want to stripe into the new striped file. After copying the file, delete the nonstriped file. Once a file is striped, you cannot use the stripe utility to modify the number of disks that a striped file crosses. To change the volume count of a striped file, you can create a second file with a new volume count, and then copy the contents of the first file into the second file. After copying the file, delete the first file. RESTRICTIONS
You cannot stripe a nonzero-length file or a file that is already striped. EXAMPLES
The following example stripes the file abc across three volumes in the same file domain: # stripe -n 3 abc The following example stripes an existing, nonzero-length file, foo, across three volumes in the same domain. First a new file, newfoo, is created and striped. Then, the contents of file foo are copied to the new, striped file: # touch newfoo # stripe -n 3 newfoo # cp foo newfoo SEE ALSO
advfs(4), showfile(8) stripe(8)
All times are GMT -4. The time now is 05:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy