Sponsored Content
Top Forums Shell Programming and Scripting don't know how to interpret this Post 302503452 by Corona688 on Thursday 10th of March 2011 03:20:12 PM
Old 03-10-2011
Quote:
Originally Posted by Straitsfan
I guess I just should have asked what the statement

$listpage

means -- does it mean to display the value of listpage, and if so, why didn't it use the echo command?
Think more literally. It's just a variable, and the shell does the same thing with variables for every statement whether they're at the beginning of the line or the end. For each statement, the shell
1) Splits apart on semicolons or pipes, and evaluates each part(turns variables into their contents, etc).
2) Executes each part.
Code:
CMD="echo"
$CMD asdf

will print 'asdf' because it
1) converts $CMD asdf into echo asdf
2) runs "echo asdf".

Now this:
Code:
CMD="ls | more"
$CMD

does this:
1) Converts $CMD into ls | more
2) Executes ls | more

See something wrong? Pipes were supposed to be handled in step 1 but weren't, because it was in a variable. Step 2 doesn't do anything to pipes, so just feeds it into ls raw. ls complains there's no such files "|" and "more".

Now this:

Code:
CMD="ls | more"
eval "$CMD"

1) Converts eval "$CMD" into eval "ls | more"
2) Executes eval "ls | more", shoving the string "ls | more" back into step 1.
1) Splits ls | more into two statements, ls and more
2) Executes ls, piping it into more.

eval's just a special keyword that bumps the shell back into step 1.

Last edited by Corona688; 03-10-2011 at 04:25 PM..
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

sar -q - how to Interpret these results

Should I be concerned about the %runocc value be always 100. The CPU is 99% idle all the time and the paging is 0 MyMachine|10/23/2007 00:00:05|1.0|100|| MyMachine|10/23/2007 00:05:04|1.0|100|| MyMachine|10/23/2007 00:10:04|1.0|100|| MyMachine|10/23/2007 00:15:04|1.0|100||... (2 Replies)
Discussion started by: SarNovice
2 Replies

2. Shell Programming and Scripting

How Do We Interpret This ?

ksh $ETL_XXX/bin/filename.ksh wf_workflowname . Which is used in post session command. (2 Replies)
Discussion started by: dummy_needhelp
2 Replies

3. UNIX for Dummies Questions & Answers

Please interpret.

Hi guys, I have no idea on unix but suddenly, my cobol programs calls a unix script that i know nothing about. can you guys interpret these lines for me? i know its a print command but I want to actually know how many copies it prints. qprt -da -P $1 -t '6' -i '6' -l '70' $2 qprt -da... (1 Reply)
Discussion started by: supacow
1 Replies

4. Shell Programming and Scripting

Can't interpret variable in if statement

Can someone help me out here. I can't get this piece of code to work. i.e. $ALL_EVENTS does not get interpreted in the if brackets. The first part is the code, the second part is the execution of the code. Note: $ALL_EVENTS does equal 2, but there is no value once passed to the if statement. ... (4 Replies)
Discussion started by: jwholey
4 Replies

5. UNIX for Dummies Questions & Answers

How to interpret TOP

Hi, So I am new to Unix, and I need to check the performance of some apps I am running. But I don't know how to interpret the output from TOP. Could somebody please explain the difference between the different values. And also explain how I can have a process which has a %CPU > 100? ... (7 Replies)
Discussion started by: dj_jay_smith
7 Replies

6. Shell Programming and Scripting

Can someone interpret this -- not sure

Was wondering if someone could interpret this for me -- I'm not sure what everything means. It's a shell script from my bash book: cd () { builtin cd "$@" es=$? echo "$OLDPWD ->$PWD" return $es } what I don't quite understand is the "$@". I think, if I understand... (6 Replies)
Discussion started by: Straitsfan
6 Replies

7. UNIX for Dummies Questions & Answers

How does Awk interpret $0!~

I know $0 is the entire file's contents (at least I think that is what it is!), but what exactly is: $0!~ This was a snippet from a larger line awk '$0!~/^$/ {print $0}' This deletes blank lines, but I want to know specifically the $0!~ part... I am guessing /^$/ is regex for blank line...... (5 Replies)
Discussion started by: glev2005
5 Replies

8. UNIX for Dummies Questions & Answers

Need to interpret code

hi All, i have never used sed in Unix environment, but i have one script which is using this following command: cat audit_session_rpt_MSP_20140331.lst|sed -n '/Apr 14/!p'| sed -n '/Page/!p'| sed -n '/UserName/!p' |\ egrep -v '^-|^=|^\*'|sed '/^$/d'|sed -e '1,7d'... (1 Reply)
Discussion started by: lovelysethii
1 Replies

9. UNIX for Beginners Questions & Answers

Who -r interpret?

I booted into single user mode with /usr/sbin/reboot -- -s but after doing a control -d my who -r shows run-level 3 Nov 17 14:07 3 0 S I was expecting it to show run-level S why is this still in run level 3? thanks (1 Reply)
Discussion started by: goya
1 Replies
AFUSE(1)						      General Commands Manual							  AFUSE(1)

NAME
AFUSE - automounting file system implemented in user-space using FUSE DESCRIPTION
usage: afuse mountpoint [options] general options: -o opt,[opt...] mount options -h --help print help -V --version print FUSE version information AFUSE options: -o mount_template=CMD template for CMD to execute to mount (*) -o unmount_template=CMD template for CMD to execute to unmount (*) (**) (*) - When executed, %r and %m are expanded in templates to the root directory name for the new mount point, and the actual directory to mount onto respectively to mount onto. Both templates are REQUIRED. (**)- The unmount command must perform a lazy unmount operation. E.g. the -u -z options to fusermount, or -l for regular mount. FUSE options: -d -o debug enable debug output (implies -f) -f foreground operation -s disable multi-threaded operation -o allow_other allow access to other users -o allow_root allow access to root -o nonempty allow mounts over non-empty file/dir -o default_permissions enable permission checking by kernel -o fsname=NAME set filesystem name -o large_read issue large read requests (2.4 only) -o max_read=N set maximum size of read requests -o hard_remove immediate removal (don't hide files) -o use_ino let filesystem set inode numbers -o readdir_ino try to fill in d_ino in readdir -o direct_io use direct I/O -o kernel_cache cache files in kernel -o umask=M set file permissions (octal) -o uid=N set file owner -o gid=N set file group -o entry_timeout=T cache timeout for names (1.0s) -o negative_timeout=T cache timeout for deleted names (0.0s) -o attr_timeout=T cache timeout for attributes (1.0s) AUTHOR
This manual page was written by Varun Hiremath <varunhiremath@gmail.com>, for the Debian project (but may be used by others). October 12, 2006 AFUSE(1)
All times are GMT -4. The time now is 10:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy