Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Why is ls output different when run in script ? Post 302824137 by Dave Allen on Thursday 20th of June 2013 08:59:14 AM
Old 06-20-2013
[Solved] Why is ls output different when run in script ?

I am running KSH shell, and use a bunch of aliases common to a group I am in.

One of them is:
Code:
 ls='ls -F'

I don't think that makes a difference to me / my issue.

Anyways, I enter (at command line): ls abc*.* and get several files listed.

I then create a script file (mls), set its perms to 777, and have it simply be one line with ls $1.

I then enter (at command line)
Code:
    mls   abc*.*

and only 1 file is listed.

Why not all that were listed with ls command directly ???

Last edited by vbe; 06-20-2013 at 10:19 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to run a script using cron job and send the output as attachment via e-mail using unix

how to run a script using cron job and send the output as attachment via e-mail using unix. please help me. how my cron job entry should be? As of now my cron job entry is to run the script at specific time, 15 03 * * * /path/sample.sh | mail -s "Logs" email_id In the above entry, what... (8 Replies)
Discussion started by: vidhyaS
8 Replies

2. Shell Programming and Scripting

Awk script to run a sql and print the output to an output file

Hi All, I have around 900 Select Sql's which I would like to run in an awk script and print the output of those sql's in an txt file. Can you anyone pls let me know how do I do it and execute the awk script? Thanks. (4 Replies)
Discussion started by: adept
4 Replies

3. Shell Programming and Scripting

Who -u gives different output if run from cron than if run from terminal?

If I run 'who -u' interactively or from a script invoked through bash in a tty on my Ubuntu 12LTS box I get an output like this: testuser pts/0 Dec 9 02:32 . 2163 (host.xx.yy) running the same through cron I get: testuser pts/0 2012-12-09 02:32 00:05 2163... (2 Replies)
Discussion started by: latimer
2 Replies

4. Shell Programming and Scripting

Why my git command has no output in crontab but works well run this script manually?

cat /home/lyang001/update.sh #!/bin/sh #shopt -s expand_aliases HOME_DIR=/home/lyang001/updates UPDATE_MAIL=${HOME_DIR}/updates.mail rm $UPDATE_MAIL -rf cd $HOME_DIR/wr-kernel git log --no-merges --since="20 day ago" --name-status --pretty=format:"%an %h %s %cd" origin/WRLINUX_5_0_1_HEAD >>... (2 Replies)
Discussion started by: yanglei_fage
2 Replies

5. Shell Programming and Scripting

How to give full access to output files created by .sh script run via crontab?

Hi Expert, I have a .sh script in my home/new_dir/script.sh This script creates number of output files at home/new_dir/email, home/new_dir/logs dir. I am running this script using crontab (owner root). Now this output files are getting created with rw-r----- 1 root root So if i... (2 Replies)
Discussion started by: Jeet1982
2 Replies

6. UNIX for Advanced & Expert Users

Script run by cron gives no output

Hi All, I have a script which checks the status of HP Smart Array & then emails me the output. The script run fine when executed manually but I receive no output when configured in a cron job. The script is below: hpacucli ctrl slot=3 show config | mail -s "ARRAY STATUS-`date`"... (6 Replies)
Discussion started by: coolatt
6 Replies

7. Shell Programming and Scripting

Run sql query in shell script and output data save as delimited text

I want to run sql query in shell script and output data save as delimited text (delimited text would be comma) Code: SPOOL_FILE=/pgedw/dan.txt SQL=/pgedw/dan.sql sqlplus -s username/password@myhost:port/servicename <<EOF set head on set COLSEP , set linesize 32767 SET TRIMSPOOL ON SET... (8 Replies)
Discussion started by: Jaganjag
8 Replies

8. Shell Programming and Scripting

A shell script to run a script which don't get terminated and send a pattern from the output by mail

Hi Guys, I am very new to shell script and I need your help here to write a script. Actually, I have a script abc.sh which don't get terminated itself. So I need to design a script to run this script, save the output to a file, search for a given string in the output and if it exists send those... (11 Replies)
Discussion started by: Sambit Sahu
11 Replies

9. Shell Programming and Scripting

Run a script before and after reboot automatically and send output to two locations.

Hello Team . I am working a health check script ( bash) to run on linux server ( RedHat) and requirements are 1. The o/p of script need to be send to two diff files . I am testing with tee command . But I am not successful yet , any recommendations if that is the right approach ? 2. The same... (2 Replies)
Discussion started by: Varja
2 Replies

10. Programming

Python script to run multiple command and append data in output csv file

Experts, I am writing a script and able to write only small piece of code and not able to collect logic to complete this task. In input file have to look for name like like this (BGL_HSR_901_1AG_A_CR9KTR10) before sh iss neors. Record this (BGL_HSR_901_1AG_A_CR9KTR10) in csv file Now have to... (0 Replies)
Discussion started by: as7951
0 Replies
subst(n)						       Tcl Built-In Commands							  subst(n)

__________________________________________________________________________________________________________________________________________________

NAME
subst - Perform backslash, command, and variable substitutions SYNOPSIS
subst ?-nobackslashes? ?-nocommands? ?-novariables? string _________________________________________________________________ DESCRIPTION
This command performs variable substitutions, command substitutions, and backslash substitutions on its string argument and returns the fully-substituted result. The substitutions are performed in exactly the same way as for Tcl commands. As a result, the string argument is actually substituted twice, once by the Tcl parser in the usual fashion for Tcl commands, and again by the subst command. If any of the -nobackslashes, -nocommands, or -novariables are specified, then the corresponding substitutions are not performed. For example, if -nocommands is specified, command substitution is not performed: open and close brackets are treated as ordinary characters with no special interpretation. Note that the substitution of one kind can include substitution of other kinds. For example, even when the -novariables option is speci- fied, command substitution is performed without restriction. This means that any variable substitution necessary to complete the command substitution will still take place. Likewise, any command substitution necessary to complete a variable substitution will take place, even when -nocommands is specified. See the EXAMPLES below. If an error occurs during substitution, then subst will return that error. If a break exception occurs during command or variable substi- tution, the result of the whole substitution will be the string (as substituted) up to the start of the substitution that raised the excep- tion. If a continue exception occurs during the evaluation of a command or variable substitution, an empty string will be substituted for that entire command or variable substitution (as long as it is well-formed Tcl.) If a return exception occurs, or any other return code is returned during command or variable substitution, then the returned value is substituted for that substitution. See the EXAMPLES below. In this way, all exceptional return codes are "caught" by subst. The subst command itself will either return an error, or will complete successfully. EXAMPLES
When it performs its substitutions, subst does not give any special treatment to double quotes or curly braces (except within command sub- stitutions) so the script set a 44 subst {xyz {$a}} returns "xyz {44}", not "xyz {$a}" and the script set a "p} q {r" subst {xyz {$a}} returns "xyz {p} q {r}", not "xyz {p} q {r}". When command substitution is performed, it includes any variable substitution necessary to evaluate the script. set a 44 subst -novariables {$a [format $a]} returns "$a 44", not "$a $a". Similarly, when variable substitution is performed, it includes any command substitution necessary to retrieve the value of the variable. proc b {} {return c} array set a {c c [b] tricky} subst -nocommands {[b] $a([b])} returns "[b] c", not "[b] tricky". The continue and break exceptions allow command substitutions to prevent substitution of the rest of the command substitution and the rest of string respectively, giving script authors more options when processing text using subst. For example, the script subst {abc,[break],def} returns "abc,", not "abc,,def" and the script subst {abc,[continue;expr {1+2}],def} returns "abc,,def", not "abc,3,def". Other exceptional return codes substitute the returned value subst {abc,[return foo;expr {1+2}],def} returns "abc,foo,def", not "abc,3,def" and subst {abc,[return -code 10 foo;expr {1+2}],def} also returns "abc,foo,def", not "abc,3,def". SEE ALSO
Tcl(n), eval(n), break(n), continue(n) KEYWORDS
backslash substitution, command substitution, variable substitution Tcl 7.4 subst(n)
All times are GMT -4. The time now is 06:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy