Sponsored Content
Top Forums Shell Programming and Scripting Process diff command output in a shell script Post 302379537 by pludi on Friday 11th of December 2009 03:02:09 AM
Old 12-11-2009
The "problem" is the way parameter expansion is done. Example:
Code:
$ cat test.sh
#!/usr/bin/ksh

VAR='Test  with  double  size  whitespace  !'

echo $VAR
echo "$VAR"
$ ksh test.sh
Test with double size whitespace !
Test  with  double  size  whitespace  !

Spot the difference? In the first example, echo is passed 6 parameters (split on the whitespaces), and by default it outputs them using one whitespace as separator. In the second example, the variable is passed as one parameter, whitespaces and all.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

diff 2 files; output diff's to 3rd file

Hello, I want to compare two files. All records in file 2 that are not in file 1 should be output to file 3. For example: file 1 123 1234 123456 file 2 123 2345 23456 file 3 should have 2345 23456 I have looked at diff, bdiff, cmp, comm, diff3 without any luck! (2 Replies)
Discussion started by: blt123
2 Replies

2. Shell Programming and Scripting

Capturing shell script command output

I am trying to check to see if a file exists on a ftp server, well, I know that cant be done, atleast directly, So I came up with this small script ftp -n $HOST <<END_SCRIPT quote USER $USER quote PASS $PASSWD cd public_html/crap dir $FILE quit END_SCRIPT Where the $ variable... (2 Replies)
Discussion started by: designflaw
2 Replies

3. Shell Programming and Scripting

reading command output from shell script

Hi List, How to read the output of a command executed from a script. For ex. sample_scritp.sh ------------- useradd testuser1 password testuser1 .... ..... -------------- This prompts for "password", and "confirm password", for which i need to give the values from script. Can... (4 Replies)
Discussion started by: sri b
4 Replies

4. Shell Programming and Scripting

parsing output from a diff command...

hi, i have a script which pipes the output of a diff -rq command into a separate file/ it would read something like this: Files mod1/lala/xml/test1.txt and mod2/lala/xml/test1.txt differ Only in mod2/lala/xml: test2.txt What i need to do is to parse this file so i end up with just a... (5 Replies)
Discussion started by: kam
5 Replies

5. Shell Programming and Scripting

Evaluating command output (shell script )

Hello, in a script i would like to evaluate a command output with a grep, for example, to know if the parameter defined by the user is in the output. Something like: the_command | grep $1 Please, how is the way to evalulate in this a script, like if echo "incorrect parameter, not in... (2 Replies)
Discussion started by: aristegui
2 Replies

6. Shell Programming and Scripting

Need help with shell script - output of top command

I have written shell script to send file as an attachemt of email and output of "top -o res" command as email body. it works fine if i execute manually from prompt but it does not send "top -o res" command output in email body when it is executed via crontab. Any suggestions. My script is below:... (5 Replies)
Discussion started by: needyourhelp10
5 Replies

7. Shell Programming and Scripting

shell script to format command output

Hello team, I am running below command which is giving following output. bash-3.00$ ps -eo pid,pcpu,args | sort +1n | grep -i java 12 0.0 grep -i java 8804 0.0 /opt/app/ccr/home/ccr/WebSphere/AppServer/java/bin/sparcv9/java -XX:+UnlockDiag 9241 0.0... (7 Replies)
Discussion started by: coolguyamy
7 Replies

8. Shell Programming and Scripting

Shell script to replace output of command

Hi I would like to write a shell script which replace particular text in output of a shell command. For example : If I execute pwd (if dir is /users/master/) it should display as - /users/Master_directory/. Also, for generalising the script I would like to receive parameters when I run the... (3 Replies)
Discussion started by: ratneshnagori
3 Replies

9. Shell Programming and Scripting

How to pipe command output to shell script?

Hi Team, Need a help on how to pipe a command out put to a shell script. My shell script looks like below. cat shell_script #!/usr/bin/ksh input =$@ echo " we are inside the shell script" echo " here are the input parameters" .......................... .................. ... (11 Replies)
Discussion started by: gvkumar25
11 Replies

10. Shell Programming and Scripting

Pass ls command output to diff

Hi , Can some one help me how to pass ls command output to diff command ex : - ls *.xml will return files which have time stamps abc-<time-stamp>.xml xyz-<time-stamp>.xml diff abc-<time-stamp>.xml xyz-<time-stamp>.xml >> newfile.txt we need to... (9 Replies)
Discussion started by: techie_09
9 Replies
SYSTEMD-ACTIVATE(8)						 systemd-activate					       SYSTEMD-ACTIVATE(8)

NAME
systemd-activate - Test socket activation of daemons SYNOPSIS
/usr/lib/systemd/systemd-activate [OPTIONS...] daemon [OPTIONS...] DESCRIPTION
systemd-activate can be used to launch a socket activated daemon from the command-line for testing purposes. It can also be used to launch single instances of the daemon per connection (inetd-style). The daemon to launch and its options should be specifed after options intended for systemd-activate. If the -a option is given, file descriptor of the connection will be used as the standard input and output of the launched process. Otherwise, standard input and output will be inherited, and sockets will be passed through file descriptors 3 and higher. Sockets passed through $LISTEN_FDS to systemd-activate will be passed through to the dameon, in the original positions. Other sockets specified with --listen will use consecutive descriptors. OPTIONS
--help, -h Prints a short help text and exits. --version Prints a short version string and exits. -l address, --listen=address Listen on this address. Takes a string like "2000" or "127.0.0.1:2001". -a, --accept Launch a separate instance of daemon per connection and pass the connection socket as standard input and standard output. -E VAR[=VALUE], --environment=VAR[=VALUE] Add this variable to the environment of the launched process. If VAR is followed by "=", assume that it is a variable-value pair. Otherwise, obtain the value from the environment of systemd-activate itself. ENVIRONMENT VARIABLES
$LISTEN_FDS, $LISTEN_PID See sd_listen_fds(3). $SYSTEMD_LOG_TARGET, $SYSTEMD_LOG_LEVEL, $SYSTEMD_LOG_COLOR, $SYSTEMD_LOG_LOCATION Same as in systemd(1). EXAMPLE 1 $ /usr/lib/systemd/systemd-activate -l 2000 -a cat This runs an echo server on port 2000. EXAMPLE 2 $ /usr/lib/systemd/systemd-activate -l 19531 /usr/lib/systemd/systemd-journal-gatewayd This runs a socket activated instance of systemd-journal-gatewayd(8). SEE ALSO
systemd(1), systemd.socket(5), systemd.service(5), cat(1) systemd 208 SYSTEMD-ACTIVATE(8)
All times are GMT -4. The time now is 07:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy