copying content of a file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers copying content of a file
# 1  
Old 03-05-2005
copying content of a file

Hi,

I have a file in my unix system let's call it FileName.
First I want to copy its content into a another file, but outside of the unix, meaning I could open it at home. (text file would be perfect)
Second (if it's possible) I need to take the first word of each line in the file (you know the first word has ended when you get to a ":" , than to each first word I need to add the same suffix (let call it SUF), and separate each first word and suffix with a ";" semi-column.
Than the result I would like to print, either on the screen or even better to a file.

can anybody help???

Thanks, Smilie

Tal
*****

Last edited by vgersh99; 03-05-2005 at 11:54 AM..
# 2  
Old 03-05-2005
firstly, pls read rules prior to posting - pay attention to #6 and #10. Pls don'tpost your email address in the future.

Although it does sound like a homework assignment - I'll give you something to start with:
Code:
 sed -e 's/^\([^:][^:]*\)/\1;SUF/' myFile

# 3  
Old 03-05-2005
Code:
awk -F: '{ print $1"SUF" }' file1 | tr '\n' ';'

 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to remove exisiting file content from a file and have to append new file content?

hi all, i had the below script x=`cat input.txt |wc -1` awk 'NR>1 && NR<'$x' ' input.txt > output.txt by using above script i am able to remove the head and tail part from the input file and able to append the output to the output.txt but if i run it for second time the output is... (2 Replies)
Discussion started by: hemanthsaikumar
2 Replies

2. Shell Programming and Scripting

Sed: replace content from file with the content from file

Hi, I am having trouble while using 'sed' with reading files. Please help. I have 3 files. File A, file B and file C. I want to find content of file B in file A and replace it by content in file C. Thanks a lot!! Here is a sample of my question. e.g. (file A: a.txt; file B: b.txt; file... (3 Replies)
Discussion started by: dirkaulo
3 Replies

3. Shell Programming and Scripting

Shell :copying the content from one file to another

I have a log containing the below lines. file1.log ----------- module: module1 module10 module2 module002 module9 moduleRT100.2.1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... (1 Reply)
Discussion started by: giridhar276
1 Replies

4. Shell Programming and Scripting

Copying lines from multiple logfiles, based on content of the line

d df d d (1 Reply)
Discussion started by: larsk
1 Replies

5. Shell Programming and Scripting

To tar the content while copying files

Any idea on how we can tar the content while copying the files from one location to another location using the bash script. (2 Replies)
Discussion started by: gsiva
2 Replies

6. UNIX for Dummies Questions & Answers

Help with searching for a file in a directory and copying the contents of that file in a new file

Hi guys, I am a newbie here :wall: I need a script that can search for a file in a directory and copy the contents of that file in a new file. Please help me. :confused: Thanks in advance~ (6 Replies)
Discussion started by: zel2zel
6 Replies

7. Solaris

Copying the content of a filesystem to different Harddrive

my server runs solaris 10 , one of the partition in my primary harddrive is 99% full , i want to move the contents of it to the second harddrive which has higher capacity. what is the best way to move the contents to 2nd drive ? which command should i use cpio/dd/tar/ufsdump .... please guide me... (1 Reply)
Discussion started by: skamal4u
1 Replies

8. UNIX for Dummies Questions & Answers

Copying the content of a filesystem to different Harddrive

my server runs solaris 10 , one of the partition in my primary harddrive is 99% full , i want to move the contents of it to the second harddrive . what is the best way to move the contents to 2nd drive ? which command should i use cpio/dd/tar/ufsdump .... please guide me with the command and the... (0 Replies)
Discussion started by: skamal4u
0 Replies

9. Shell Programming and Scripting

Copying selected content from file

I want to capture contents of a file between 2 strings into another file for eg all lines in between the keywords "start log" and "end log" should be copied into another file (1 Reply)
Discussion started by: misenkiser
1 Replies
Login or Register to Ask a Question