Can anyone explain this behavior?
Running:
#!/bin/shecho "hello world" | read var1 var2echo $var1echo $var2
results in nothing being ouput, while:
#!/bin/shecho "hello world" > test.fileread var1 var2 < test.fileecho $var1echo $var2
produces the expected output:
helloworld
Shouldn't the pipe do in one step what the redirection to t...
I was looking at http://tldp.org/LDP/abs/html/why-shell.html and was struck by:
When not to use shell scripts
...
Mission-critical applications upon which you are betting the future of the company
Why not?
...
I'm looking for shell scripts files installed on my system, but find doesn't work:
$ find /usr -name *.sh
But I know there are a ton of scripts out there. For instance:
$ ls /usr/local/lib/*.sh
/usr/local/lib/tclConfig.sh
/usr/local/lib/tkConfig.sh
Why doesn't find work?
...
When I do:
$ find /
It searches the entire system. How do I prevent that?
(This question comes from an "answer" to another question.)
...
Using the same sort command with the same input produces different results on different machines. How do I fix that?
...
When I try to use an ssh command in a shell script, the command just sits there. Do you have an example of how to use ssh in a shell script?
...
I have some ksh scripts which I'd like to convert to run with bash instead.
Are there any useful on-line resources for this?
I'm really looking for a list of differences between the two shells and any gotchas I might encounter, although all information is welcome :-)
...
Need to parse some basic XML (one root element, 3-4 subelements, 1-3 attributes each) from a ksh script (ideally stick to ksh, given the script already exists and it's just trying to read some extra configuration created in XML by another program).
I know I can use sed and do pattern matching, but it's not foolproof given that the input...
Currently I monitoring a particular file with a simple shell one-liner:
filesize=$(ls -lah somefile | awk '{print $5}')
I'm aware that Perl has some nice modules to deal with Excel files so the idea is to, let's say, run that check daily, perhaps with cron, and write the result on a spreadsheet for further statistical use.
...
I am involved in the process of porting a system containing several hundreds of ksh scripts from AIX, Solaris and HPUX to Linux. I have come across the following difference in the way ksh behaves on the two systems:
#!/bin/ksh
flag=false
echo "a\nb" | while read x
do
flag=true
done
echo "flag = ${flag}"
exit 0
On AIX, Solaris and ...
I'm not new to *nix, however lately I have been spending a lot of time at the prompt to do my development for my job. My question is what are the advantages of using Korn Shell or Bash Shell? Where are the pitfalls of using one over the other? Looking to understand from the perspective of a user, rather than purely scripting.
...
I've recently had to dust off my Perl and shell script skills to help out some colleagues. The colleagues in question have been tasked with providing some reports from an internal application with a large Oracle database backend, and they simply don't have the skills to do this. While some might questions whether I have those skills eith...
In the Korn shell on AIX UNIX Version 5.3 with the editor mode set to vi using:
set -o vi
What are the key-strokes at the shell command line to autocomplete a file or directory name ?
...
I have uncovered another problem in the effort that we are making to port several hundreds of ksh scripts from AIX, Solaris and HPUX to Linux. See here for the previous problem.
This code:
#!/bin/ksh
if [ -a k* ]; then
echo "Oh yeah!"
else
echo "No way!"
fi
exit 0
(when run in a directory with several files whose name starts ...
I need to attach a file with mailx but at the moment I'm not having a lot of success.
Here's my code:
subject="Something happened"
to="[email protected]"
body="Attachment Test"
attachment=/path/to/somefile.csv
uuencode $attachment | mailx -s "$subject" "$to" << EOF
The message is ready to be sent with the following file or link a...
Okay, I'm sure this is simple but it is driving me nuts. I recently went to work on a program where I've had to step back in time a bit and use Redhat 9. When I'm typing on the command line from a standard xterm running Korn shell, when I reach the end of the line the screen slides to the right (cutting off the left side of my command) i...
I try to write KSH script for processing a file consisting of name-value pairs, several of them on each line.
Format is:
NAME1 VALUE1,NAME2 VALUE2,NAME3 VALUE3, etc
Suppose I write:
read l
IFS=","
set -A nvls $l
echo "$nvls[2]"
This will give me second name-value pair, nice and easy. Now, suppose that the task is extended so that ...
I have a file with fields separated by pipe characters and I want to print only the second field. This attempt fails:
$ cat file | awk -F| '{print $2}'
awk: syntax error near line 1
awk: bailing out near line 1
bash: {print $2}: command not found
Is there a way to do this?
...
What is the most elegant way to calculate the previous business day in shell ksh script ?
What I got until now is :
#!/bin/ksh
set -x
DAY_DIFF=1
case `date '+%a'` in
"Sun")
DAY_DIFF=2
;;
"Mon")
DAY_DIFF=3
;;
esac
PREV_DT=`perl -e '($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time()-${DAY_DIFF}*24*60*60...
I have this large C++ project that I need to build on a platform that does not have a parallel make (like make -j on Linux). The server has 6 CPU's and I want to do a parallel build manually.
I can generate a task list like this for about 300 object files. I use the Makefile for the dependency checks and incremental build:
make -f Mak...