New answers tagged

3

Your script has a few issues: The error stems from the export line. You are using $SERVER as a command, and this command can not be found. What you'd like to do is to feed the string into cut: print $SERVER | cut -c1-2,5-10 | ... The line SERVER="echo `hostname`" is better written SERVER=$(hostname) The tr utility takes character ranges, so there's ...


2

Most tutorials you can find are about bash. Ksh is very good at scripting but is bad at interactive use. Use zsh (best) or bash (second-best) as a command line if you can. There are two main implementations of ksh today: the actual Korn shell ksh93, and the clone mksh (derived from the long-unmaintained pdksh). They have different key binding facilities. ...


1

My actual problem was that (in contrast to the simplified example in my question), I actually massaged the jobs output in a function, separating running from stopped jobs. This is my code for Bash: typeset runningJobs=$(jobs -r | wc -l) typeset stoppedJobs=$(jobs -s | wc -l) which I ported to Korn shell in this way: typeset runningJobs=$(jobs | grep -c '...


2

By default if you just set PS1="...." then the stuff inside the quotes is evaluated at the time you set it. However if you enclose it inside ' instead then it's evaluated at display time. And it doesn't cause a subshell for $(jobs). e.g. $ PS1=' > $(jobs) > $ ' $ sleep 1000 & [1] 7541 [1] + Running sleep 1000 & $ sleep ...


1

Just run your whole install script under setarch $ setarch $(uname -m) --uname-2.6 /path/to/install/script.sh Everything called in that script onwards will think you're running a 2.6 kernel.


2

I would use paste here. It's a nifty tool that can be used to combine files: $ paste printdirs.txt archivedirs.txt /u/lawson/law/print/lawson/tim/1 /u/lawson/law/print/archive /u/lawson/law/print/dgfinance/monday190/1 /u/lawson/law/print/archive2 As you can see above, it will print successive lines from both files, separated by tabs. The tab-...


1

I don't think find has an option like this, you could build a command using printf and your exclude list: find . -name "*.txt" $(printf "! -name %s " $(cat file.txt)) -mtime +60 -exec rm -f {} + file.txt will have list of files to exclude in find command.


2

Assuming your files have sane names (i.e. they don't have embedded newlines), something like this should work: find . -mtime +60 | fgrep -v -x -f exceptions.txt | xargs -d '\n' rm -f Replace rm -f with ls -1 for a dry run first. Put paths exactly as they are printed by find in exceptions.txt.


2

Turns out it is documented behaviour. From the ksh93 man page: Search Edit Commands These commands access your command history. [count]k Fetch previous command. Each time k is entered the previous command back in time is accessed. [count]- Equivalent to k. [count][A If cursor is at the end of the line it is equivalent to / ...


0

My understanding is that prior to RHEL 6, Red Hat were wary of the AT&T KornShell because of its licence, so they included the pdksh, which is a less complete implementation. I think David Korn was doing his best to get ksh accepted in as many places as possible and somewhere along the line the licence was clarified or changed. This quote is from the ...



Top 50 recent answers are included