The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
what is wrong with this tr -d? cleansing_flame UNIX for Dummies Questions & Answers 3 02-06-2008 12:34 PM
What’s wrong with the following? vrn UNIX for Dummies Questions & Answers 8 03-19-2006 09:09 PM
where have i gone wrong? Blip Shell Programming and Scripting 3 01-28-2004 04:43 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-04-2007
iago iago is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 20
what am i doing wrong

#!/bin/bash
$1 | cat >> - $2

I am trying to write a script that takes that takes two arguments. The first being a line of text, the second being a file you create. The script should take the first argument and insert it into the very top (the first line) of the file named in your second argument

Cant see whats wrong with the above. Anyone any clues.
  #2 (permalink)  
Old 09-04-2007
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
Code:
#!/bin/bash
echo $1 | cat - $2
This will output the first arg followed by the contents of the file named in the second arg on screen.
  #3 (permalink)  
Old 09-04-2007
iago iago is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 20
yeah i know but i want to save the output to the file of the second argument? any ideas
  #4 (permalink)  
Old 09-04-2007
HIMANI's Avatar
HIMANI HIMANI is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 20
Try this :

cp $2 $2_temp
awk -v val1=${1} -F , 'BEGIN {
print val1
}' > temp

cat temp $2_temp > $2
rm temp $2_temp
  #5 (permalink)  
Old 09-04-2007
iago iago is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 20
not allowed use awk or sed
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:00 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0