Shell script dynamic command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell script dynamic command
# 1  
Old 03-10-2010
Shell script dynamic command

I need to run a shell script with dynamic command in it like

Code:
# Begin script...
 
mysql xx "select * from tab"  | sed 's/\t/|/g' > GENERATED_20100304.txt

the dynamic part is 20100304 which should be today's date, and it needs to run every day and create a new file with GENERATED_YYYYMMDD.txt

Any thoughts ?

Last edited by Scott; 03-10-2010 at 06:30 PM.. Reason: Code tags
# 2  
Old 03-10-2010
Like so?:

Code:
DATE=$(date '+%Y%m%d')

# Begin script...

mysql xx "select * from tab" | sed 's/\t/|/g' > GENERATED_$DATE.txt

# 3  
Old 03-10-2010
Thanks Scott.

I overlooked $(date '+%Y%m%d') ' single quote earlier.

You know how we can avoid ^m chars ? im getting it at the end of the file.

Thanks again.

---------- Post updated at 08:28 PM ---------- Previous update was at 08:11 PM ----------

dos2unix did the trick. Thanks anyways.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Printf command , a little more dynamic..

A big hello to everyone tagged to this site of knowledge . This is the first post of mine and I am looking forward to an enjoyable stint in this forum where I get to know a lot of new ideas and share whatever knowledge (its not much though :) ) I have acquired throughout my career so far with... (4 Replies)
Discussion started by: kumarjt
4 Replies

2. Shell Programming and Scripting

Dynamic checkbox(HTML page) for each process using shell script

Hi friends, I m newbie to bash scripting , i m writing script(bash) that will display all processes which r running in my system in an html page, everything going fine but i m not able to get checkbox dynamically for each process in html page ,so that i can mark that process... (2 Replies)
Discussion started by: vagga06
2 Replies

3. Shell Programming and Scripting

Passing dynamic value to shell script

Hi Team, I'm using HP UX. I want to pass a variable dynamically as input while executing the script and that value need to be replaced with a string in the script. I tired SED, in the command line its working but while I keep the same command in the script its not working. Can someone help me... (4 Replies)
Discussion started by: hazel
4 Replies

4. Shell Programming and Scripting

Dynamic SQL query based on shell script parameters

Hi, I need a script that will run a dynamic Oracle SQL. Dynamic meaning the SQL statement depends on the parameter. For instance, something like this: #!/bin/ksh -x # Set environment . /home/mine/set_vars sqlplus $LOGINID <<! >> /home/mine/log.txt select count(1) from $1 where... (2 Replies)
Discussion started by: laiko
2 Replies

5. Shell Programming and Scripting

dynamic editing using shell script

Hi, I would like to edit an input data-file by changing a variable in it in steps: For ex: If my input file is 'big.in', then it has the following data: 2.54 0.01 0.5 0.0 My source code then reads this above line, executes and gives out some output. Then , I want to increment... (1 Reply)
Discussion started by: habzone2007
1 Replies

6. Shell Programming and Scripting

creating dynamic shell script

Hello I am trying to create a dynamic ksh script and I have an issue. I have a script a.ksh and it has got the following lines (for example) #!/bin/ksh # trace mode +x : without trace -x : with trace set +xv echo hi, i am going to create a dynamic script now cat >> dynamic.ks <<EOF... (2 Replies)
Discussion started by: sundarkumars
2 Replies

7. Shell Programming and Scripting

passing a list of dynamic names to a "PS" command in shell script?

Hi, I am new to shell script. This is my first post .I have written a small script which returns list of names starts with "ram" in /etc/passwd .Here is that:- #!/bin/ksh NAME_LIST="name_list.txt" cat /dev/null > $NAME_LIST evalcmd="cat /etc/passwd | grep "^ram?*" | cut -d: -f1" eval... (3 Replies)
Discussion started by: sachin.tendulka
3 Replies

8. Shell Programming and Scripting

Dynamic variables within shell script

Hi Gurus, I have a requirement of writting the shell script where it should ask me two values FND_TOP=/d02/app/oracle/xxx/fnd/11.5.0 CDCRM_TOP=/d02/app/oracle/xxx/cdcrm/11.5.0 and then keep these values stored as variables for the execution of rest of the script. Because, I have to... (2 Replies)
Discussion started by: isingh786
2 Replies

9. Shell Programming and Scripting

Shell Script Run Interval to be dynamic

Hi All. I have a script which has to be run periodically. The frequency of its run will be decided by a Database stored value PollRate. e.g. If PollRate value is 300secs, then the script should be executed every 5 minutes, if it's 1500secs, it should execute every 15 minutes. Is there... (5 Replies)
Discussion started by: rahulrathod
5 Replies

10. Shell Programming and Scripting

search and replace dynamic data in a shell script

Hi, I have a file that looks something like this: ... 0,6,256,87,0,0,0,1187443420 0,6,438,37,0,0,0,1187443380 0,2,0,0,0,10,0,1197140320 0,3,0,0,0,10,0,1197140875 0,2,0,0,0,23,0,1197140332 0,3,0,0,0,23,0,1197140437 0,2,0,0,0,17,0,1197140447 0,3,0,0,0,17,0,1197140543... (8 Replies)
Discussion started by: csejl
8 Replies
Login or Register to Ask a Question