Sponsored Content
Top Forums Shell Programming and Scripting Shell script newbie, what is problem with my script? Post 302619535 by Corona688 on Thursday 5th of April 2012 04:01:58 PM
Old 04-05-2012
Sorry, I missed your second question.

There's two differences.
  • ls prints lines of text. * sets arguments.
  • ls is an external program. * is a shell operator.

Arguments are the things you feed into a program, like so:

Code:
./myprogram 1 2 3

argument 1 would be 1, and so forth.

'echo' doesn't actually understand what * means. The shell translates * into a list of files for you, before the program is run. So you can use * anywhere a list of file arguments makes sense!

ls on the other hand, reads filenames by itself. It also has options to sort them (-t means sort by time ), and print extended information ( -l ) which * cannot do.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Newbie using sed in a shell script

I'm sure this is an easy one but I can't seem to get it working. Given the following: for oldName in `ls *.JPG` ;do newName=<confusion here. how to make sed perform 's/.JPG/_thumb.JPG/g' operation on $oldName> done Could someone show me what I'm doing wrong? Thanks Ken (1 Reply)
Discussion started by: ktoz
1 Replies

2. Shell Programming and Scripting

Newbie problem with ksh script

Hi all, I have a directory have all of the .stat and .dat file : they are is a pipe separate flat file. Example: log-20061202.stat contain 1st line and last line of log-20061202.dat with record count of that day. Example: Total record = 240 Tom|02-12-2006|1600 W.Santa... (18 Replies)
Discussion started by: sabercats
18 Replies

3. Shell Programming and Scripting

NEWBIE: If and Find in shell script

Basically I have a shell script and i want to search the computer for a folder and if that folder exists i want to take some action. Not sure exactly how to do this most efficiently. Not very experienced....any help would be appreciated. (1 Reply)
Discussion started by: meskue
1 Replies

4. Shell Programming and Scripting

A newbie with a problem in A date Script

Hello everybody... I'm a Unix newbie and i just got this task at work to figure out what's wrong with a daily script my team is using. The idea behind the script is that it takes the day before in a yyyymmdd format, find files with that date in a specific directory and executes an (irrelavant)... (4 Replies)
Discussion started by: adija
4 Replies

5. Shell Programming and Scripting

A few questions from a newbie(shell script)

Q1>How do i read and write to file in shell script. Here is what i want let's assume the filename as "file1" Read file1 Check the content of file1 which can be either "0" or "1" if(content == 0) { execute a command } flush file1(remove all contents in it) write "1" in to... (5 Replies)
Discussion started by: perk_bud
5 Replies

6. Shell Programming and Scripting

Help - shell script newbie

My problem looks like it should have a simple solution but it seems that after many days of research I cannot find a good solution. What I have is an input file that contains lines of information. What I need is to extract specific information from that file. What I know is that somewhere in the... (2 Replies)
Discussion started by: eback
2 Replies

7. Shell Programming and Scripting

Newbie problem with simple script to create a directory

script is: dirname= "$(date +%b%d)_$(date +%H%M)" mkdir $dirname should create a directory named Nov4_ Instead I get the following returned: root@dchs-pint-001:/=>./test1 ./test1: Nov04_0736: not found. Usage: mkdir Directory ... root@dchs-pint-001:/=> TOO easy, but what am I... (2 Replies)
Discussion started by: gwfay
2 Replies

8. Shell Programming and Scripting

Shell Script Help -I'm a newbie

Can someone help me write this shell script? I am completely new to shell and as a fun task my uncle has challenged me a problem (out of all other people). Basically, all he wants me to do is to create backup file in a folder that is named “disables.” This is what he said: create a shell script... (0 Replies)
Discussion started by: hotcutiepie05
0 Replies

9. Shell Programming and Scripting

Shell Script for a newbie

Hello all, I want to write a shell script to list the contents of a directory and number them and write them to a file. For example, if I have a directory temp and the contents of the directory are alpha, beta and gamma. I want to write these filenames to a file "test" in a numbered manner. ... (7 Replies)
Discussion started by: grajp002
7 Replies

10. UNIX for Beginners Questions & Answers

Shell script newbie- how to generate service log from shell script

Hi, I am totally a newbie to any programming languages and I just started an entry level job in an IT company. One of my recent tasks is to create a script that is able to show the log file of linux service (i.e. ntpd service) lets say, if I run my script ./test.sh, the output should be... (3 Replies)
Discussion started by: xiaogeji
3 Replies
SHUFFLE(1)						    BSD General Commands Manual 						SHUFFLE(1)

NAME
shuffle -- print a random permutation of the command line arguments SYNOPSIS
shuffle [-0] [-f filename ...] [-n number] [-p number] [arg] [...] DESCRIPTION
The shuffle program prints a random permutation (or ``shuffle'') of its command line arguments. This can be useful in shell scripts for selecting a random order in which to do a set of tasks, view a set of files, etc. If the -f option is given, the data is taken from that files' contents or if the filename is - ``stdin''. If the -n option is given, its argument is treated as a number, and the program prints a random permutation of the numbers greater than or equal to 0 and less than the argument. If the -p option is given, its argument is treated as a number, and the program prints that number of randomly selected lines or arguments in a random order. The -0 option changes the field separator character from to , so that the output is suitable to be sent to xargs(1) (to handle filenames with whitespace in them). EXAMPLES
$ shuffle a b c d c b d a $ shuffle -p 1 a b c d d $ shuffle -n 4 -p 2 0 3 SEE ALSO
jot(1), random(6) HISTORY
The shuffle program first appeared in NetBSD 1.4. AUTHORS
Written by Perry E. Metzger <perry@piermont.com>. BSD
February 18, 2009 BSD
All times are GMT -4. The time now is 07:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy