Tag Info

Hot answers tagged

5

tar cjf <your-name-in-specific-path> <your-directory-path> c: Create j: Use bzip2 for compression f: Save it to given file name NOTE: If your tar version doesn't have these options you can follow the below instruction: tar cf <your-name-in-specific-path> <your-directory-path> gzip ...


3

Tar in AIX by default does not support compression. You will need to incorporate with gzip command to have it tar and compress at the same time. $ tar cvf test.tar test # pure tar only $ tar cvf - test | gzip > test.tar.gz # tar and compress together To uncompress and untar: $ gunzip -c test.tar.gz | tar tvf - # ...


3

If you don't have ksh93 available, you can do it in standard ksh like this: function capitalize { typeset -u first first=${1%"${1#?}"} print "${first}${1#?}" } ${1#?} strips all characters matching "?" from the beginning of the first arg. i.e. strips off the first character ${var%pattern} strips off pattern from the end of var. If we use the ...


3

A directory cannot be compressed, because a directory is not a plain file. It is a pointer to a container of a set of files. You can tar a directory and its contents into a single file and compress that file. Or you can cd into the directory and compress each individual file.


2

Here's a POSIX-compliant way of testing whether dir is empty using only built-in shell constructs. The set command sets the positional arguments to dot files (including the always-existing . and ..) followed by non-dot files. If the directory is empty then the .* glob only matches . and .., and the * glob matches nothing so remains unexpanded. set dir/.* ...


2

If your variable is exported (bash: by the export command or by default because of set -a) then a called shell gets it in its environment like any other process would.


2

Use read x='';while [[ "$x" != "A" ]]; do read -n1 x; done read -n 1 is to read 1 character. This should work in bash but you can check if it works in ksh


2

This is used to get the filename from the full path. This is similar to using the basename command. Example: filename="/tmp/test.txt" echo "$filename" "${filename##*/}" /tmp/test.txt test.txt basename "$filename" test.txt``


2

Items in crontab execute with a limited environment. At the top of your script you can specify your PATH, for example, PATH=$PATH:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin or alternatively you can call each executable with its absolute path.


2

lastUpdate="$(stat -c %Y myLogFile.log)" now="$(date +%s)" let diff="${now}-${lastUpdate}"


2

I can't say exactly for ksh, but from the experience with other shells - they cache current session history and push it to the file on exit. So history file removal affects on a new session, not the currently opened.


1

Variables are interpreted in a here doc (<<...), so you need to escape the ones you don't want evaluated yet. su - db2prd<<EOF PARMDATE=1111111 echo parmdate echo \$PARMDATE EOF


1

You added break in the yes statement, so it is exiting the for-loop and therefore not finish testing the rest of the array. Just remove break from the 'yes' case statement. I tested with some modifications to your code, and got what I believe are your expected results: #!/bin/sh arrs=(a b c d) num=`expr ${#arrs[*]} - 1` for x in `seq 0 $num` do ...


1

You can make ksh load another file at start by setting ENV in $HOME/.profile point to a readable file. ksh will run that file as a script. Example: $ echo 'ENV=$HOME/custom_kshrc' >> ~/.profile $ echo 'export ENV' >> ~/.profile $ . ~/.profile $ printf 'AAA=QQQ\nexport AAA\necho Done\n' > custom_kshrc $ ksh Done % env | grep AAA AAA=QQQ


1

set -- while [ "$(($#>5))" -eq "-${#status}" ] do "test"; ${status:+":"} sleep 3 set '' "$@" done If you test by complement you can often do a lot more with one test.


1

The man page of your shell will usually help. Lets take your first example. if [ $? -ne 0 ]; then On my system man ksh says: if list ;then list [ ;elif list ;then list ] ... [ ;else list ] ;fi The list following if is executed and, if it returns a zero exit sta‐ tus, the list following the first then is executed. Otherwise, ...


1

You'd get that error message if you had turned the -u option either by invoking ksh as ksh -u or ksh -o nounset or by running set -u or set -o nounset. touch $var1 $var2 $var3 is wrong anyway unless those variables are meant to contain lists of file patterns. It should have been: touch -- "$var1" "$var2" "$var3" Now, if you want to allow one of them to ...


1

Simply add a minus sign: TZ=ZZZ0 touch -t "$(TZ=ZZZ-0:30 date +%Y%m%d%H%M.%S)" $HOME/reference Or invert your timezone trick: TZ=ZZZ0:30 touch -t "$(TZ=ZZZ0 date +%Y%m%d%H%M.%S)" $HOME/reference If you need to go beyond the range of timezone offsets, standard shell utilities notoriously lack a way to manipulate date. Various people have done the job of ...


1

Try to pipe otput via sed 's/\S\+ \(= \|in (\)/\1/g'


1

Your script does cat wlr3queue.txt etc.... where are those files to be found? When you're trying by hand you're running ./wlr3queuetransaction.sh but from cron you're calling with the complete pathname. Cron will run your command from the crontab's owner's home directory; presumably the files you're accessing in your script aren't in that home directory. ...



Only top voted, non community-wiki answers of a minimum length are eligible