Sponsored Content
Top Forums Shell Programming and Scripting passing data to another file on mac Post 302623839 by digitalviking on Saturday 14th of April 2012 09:09:29 PM
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 More Discussions You Might Find Interesting

1. 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

2. 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
shells(4)							   File Formats 							 shells(4)

NAME
shells - shell database SYNOPSIS
/etc/shells DESCRIPTION
The shells file contains a list of the shells on the system. Applications use this file to determine whether a shell is valid. See getuser- shell(3C). For each shell a single line should be present, consisting of the shell's path, relative to root. A hash mark (#) indicates the beginning of a comment; subsequent characters up to the end of the line are not interpreted by the routines which search the file. Blank lines are also ignored. The following default shells are used by utilities: /bin/bash, /bin/csh, /bin/jsh, /bin/ksh, /bin/ksh93, /bin/pfcsh, /bin/pfksh, /bin/pfsh, /bin/sh, /bin/tcsh, /bin/zsh, /sbin/jsh, /sbin/sh, /usr/bin/bash, /usr/bin/csh, /usr/bin/jsh, /usr/bin/ksh, /usr/bin/ksh93, /usr/bin/pfcsh, /usr/bin/pfksh, /usr/bin/pfsh, and /usr/bin/sh, /usr/bin/tcsh, /usr/bin/zsh, and /usr/sfw/bin/zsh. /etc/shells overrides the default list. Invalid shells in /etc/shells could cause unexpected behavior, such as being unable to log in by way of ftp(1). FILES
/etc/shells list of shells on system SEE ALSO
vipw(1B), ftpd(1M), sendmail(1M), getusershell(3C), aliases(4) SunOS 5.11 20 Nov 2007 shells(4)
All times are GMT -4. The time now is 05:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy