passing data to another file on mac


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting passing data to another file on mac
# 1  
Old 04-14-2012
passing data to another file on mac

Code:
#!/bin/bash

dir=/testdir

cat > testfile.sh << EOFILE
#!/bin/bash

path=`find "$dir" -maxdepth 100 -mindepth 1 -type d | while read line;do echo $RANDOM'|'$line;done |sort|cut -d"|" -f2- | head -1`

EOFILE

chmod 755 testfile.sh

exit 0

I have an issue with the above code. Again in Ubuntu it works but on a mac it tries to read the command starting path=`find...

This causes the variables in the command to go missing or shows weird output.

Is there an easier way to get the file the write properly

As always thanks

Cheers
DV

Last edited by digitalviking; 04-14-2012 at 10:35 PM..
# 2  
Old 04-15-2012
loose second #!/bin/bash
# 3  
Old 04-16-2012
substitution in specific line number

sorry
Login or Register to Ask a Question

Previous Thread | Next Thread

2 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing data from csv to script

Hi I have a bash script as such: cat $csvdir/$csvfile | csvdsx -ePlanned \ -iCell:CELLID \ -cCells%BTS:SITEID^Cell:CELLID \ -sCell:CELLID \ --multi-value-field=$paramname \ -xCELLID,SITEID \ ->$dsxdir/$dsxfile It basically converts a csv file to a dsx file My csv file... (1 Reply)
Discussion started by: ladyAnne
1 Replies

2. Shell Programming and Scripting

Passing data from file to variables for script

Hello all! After searching through numerous helpful posts on these forums I am still having an issue with a task I am trying to accomplish. I am trying to take data from an input file, store the contents as variables, and use the variables in the script. The input file (input.txt) is... (2 Replies)
Discussion started by: screwed718
2 Replies
Login or Register to Ask a Question