LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 05-25-2006, 05:36 AM   #1
b123coder
Member
 
Registered: Nov 2004
Location: india
Distribution: Fedora core 1
Posts: 67

Rep: Reputation: 15
shell script for expanding lines in a file


need shell script that will convert existing file's contents from
/misc/file1
/misc/file/file2
/misc/file3/file4/file5

to

cp /misc/file1 /opt/my/files/misc/file1
cp /misc/file/file2 /opt/my/files/misc/file/file2
cp /misc/file3/file4/file5 /iopt/my/files/misc/file3/file4/file5
 
Old 05-25-2006, 05:51 AM   #2
debulu
Member
 
Registered: May 2006
Location: India
Distribution: Redhat
Posts: 49

Rep: Reputation: 15
Hi b123coder,
My script uses the filename as "test". You can give your file name and test it...
Enjoy

#!/bin/bash
filename="test"
word="cp ";
append="/opt/my/files"
cat $filename|while read line
do
echo "$word$line $append$line" >> tempfile;
done
cat tempfile > $filename;
rm -f tempfile;
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
expanding variable in shell script dipenchaudhary Programming 8 02-08-2006 06:05 PM
How can I use a shell script to add and replace lines in a file? abefroman Programming 10 12-27-2005 06:05 PM
Shell Script (adding a prefix to output lines) rheza Programming 3 01-04-2005 02:18 PM
[c shell] How do I find how many lines a file has? saiz66 Programming 5 10-08-2004 04:01 PM
shell script to copy lines from a file Warmduvet Programming 2 09-14-2004 10:25 PM


All times are GMT -5. The time now is 08:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration