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
bidiv(1)							       Ivrix								  bidiv(1)

NAME
bidiv - bidirectional text filter SYNOPSIS
bidiv [ -plj ] [ -w width ] [file...] DESCRIPTION
bidiv is a filter, or viewer, for birectional text stored in logical-order. It converts such text into visual-order text which can be viewed on terminals that do not handle bidirectionality. The output visual-order text is formatted assuming a fixed number of characters per line (automatically determined or given with the -w parameter). bidiv is oriented towards Hebrew, and assumes the input to be a Hebrew and ASCII text encoded in one of the two common logical-order encod- ings: ISO-8859-8-i or UTF-8. Actually, bidiv guesses the encoding of its input at a character by character basis, so the input might be a mix of ISO-8859-8-i and Hebrew UTF-8. bidiv's output is visual-order text, in either the ISO-8859-8 or UTF-8 encoding, depending on your locale setting. bidiv reads each file in sequence, converts it into visual order and writes it on the standard output. Thus: $ bidiv file prints file on your terminal (assuming it has the appropriate fonts, but no bidirectionality support), and: $ bidiv file1 file2 | less concatenates file1 and file2, and shows the results using the pager less. If no input file is given, bidiv reads from the standard input file. For more ideas on how to use bidiv, see the EXAMPLES section below. OPTIONS
-p Paragraph-based direction (default): When formatting a bidirectional output line, bidiv needs to be aware of that line's base direc- tion. A line whose base direction is RTL (right to left) gets right-justified and its first element appears on the right. Otherwise, the line is left-justified and its first element appears on the left. The -p option tells bidiv to choose a base direction per paragraph, where a paragraph is delimited by an empty line. This is bidiv's default behavior, and usually gives the expected results on most texts and emails. The direction of the entire paragraph is chosen according to the first strongly-directioned character (i.e., an alphabetic charac- ter) appearing in the paragraph. Currently, if the first output line of a paragraph has no directional characters (e.g., a line of minus signs before an email signature, or a line containing only numbers) that line is output with the same direction of the previ- ous paragraph, but it does not determine the direction of the rest of the paragraph. If the first line of the first paragraph does not have a direction, the RTL direction is arbitrarily chosen. -l Line-based direction: This option choose an alternative method of choosing each output line's base direction. When this option is enabled, the base direction of each output line is determined on its own (again, according to the first character on the line with a strong direction). This method may give wrong results in the case where a line starts with a word of the opposite direction. This case is rare, but does happen under random line-splitting circumstances, or when the text is defining words of a foreign language. -j Do not justify: By default, RTL lines are right-justified, i.e., they are padded with spaces on the left when shorter than the required line width (see the -w option). The -j option tells bidiv not to preform this justifications, and leave short lines unpadded. -w width bidiv formats its output for lines of the given width. Lines are split when longer than this width, and RTL lines are right-justfied to fill that width unless the -j option is given. When the -w option is not given, bidiv uses the value of the COLUMNS variable, which is usually automatically defined by the user's shell. When that both the -w option and the COLUMNS variable are missing, the default of 80 columns is used. OPERANDS
The following operand is supported: file A path name of an input file. If no file is specified, the standard input is used. EXAMPLES
1. bidiv README | less 2. man something | bidiv | less (or groff -man -Tlatin1 something.1 |sed 's/.^H(.)/1/g' |../bidiv -w 65) 3. set "bidiv" as a filter for your mail program (mutt, pine, etc.) for viewing mail with the ISO 8859-8-i character set, and Hebrew UTF-8 mail. ENVIRONMENT
COLUMNS see -w option. EXIT STATUS
The following exit values are returned: 0 All input files were output successfully. >0 An error occurred. AUTHOR
Written by Nadav Har'El, http://nadav.harel.org.il. Please send bug reports and comments to nyh@math.technion.ac.il. The latest version of this software can be found in ftp://ftp.ivrix.org.il/pub/ivrix/src/cmdline SEE ALSO
cat(1), fribidi(3) Bidiv 7 Jan 2006 bidiv(1)
All times are GMT -4. The time now is 08:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy