ksh

Korn Shell - Creating a fixed width text file

I need to create a simple fixed width text file in KShell. My current attempt using printf to pad the string isn't working out very well. What's the shortest, cleanest way to create a fixed width string in shell? ...

vi editor query

I use vi quite often to edit files. Usually I need the file to appear on screen with line numbers. For this I do set nu in edit mode. What a drag! Can I automate this? Is there any way where vi will directly open the file with line numbers visible immediately? If so, are there any other tips that will make my experience with vi more eff...

strange behavior when using recursion in ksh93

I'm facing some problems in ksh93, when going through directories recursively. create some files and directories. base=/tmp/nonsens for i in {1..3} do mkdir -p ${base}/dir${i} for j in {1..2} do mkdir ${base}/dir${i}/dir${j} touch ${base}/dir${i}/dir${j}/file${j} touch ${base}/dir${i}/file${j} d...

$$ in ksh shell

Please tell me the meaning of $$ in ksh shell? I guess it is associated with the process id but I want to know its exact meaning. ...

changing to parent directory in unix

in general we use cd .. for going to the parent directory cd ../../ to go to the parents parent directory. and cd ../../../../../ for 5th parent directory. is there any simplified way of doing this? shell i am using is ksh. ...

How can I flush the input buffer in an expect script?

I'm writing an Expect script and am having trouble dealing with the shell prompt (on Linux). My Expect script spawns rlogin and the remote system is using ksh. The prompt on the remote system contains the current directory followed by " > " (space greater-than space). A script snippet might be: send "some command here\r" expect " > " ...

Korn Shell - Test with variable that may be not set

I have the following code in KornShell FAILURE=1 SUCCESS=0 isNumeric(){ if [ -n "$1" ]; then case $1 in *[!0-9]* | "") return $FAILURE; * ) return $SUCCESS; esac; else return $FAILURE; fi; } #... FILE_EXT=${FILE#*.} if [ isNumeric ${FILE_EXT} ]; then echo "...

Difference between test -h and test -L

What is the difference between test -L filename and test -h filename in ksh shell. From the man page, both were used to identify a symbolic link, but I want to know the exact difference. Here is the description from the man page. -h file True if file exists and is a sym- bolic link. -L file...

How to manage reports/files distribution to different destinations in Unix?

The reporting tools will generate a huge numbers of reports/files in the file system (a Unix directory). There's a list of destinations (email addresses and shared folders) where a different set of reports/files (can have overlap) are required to be distributed at each destinations. Would like to know if there's a way to efficiently man...

understanding a ksh script part of

Hi Could someone help me understand the following piece of code which is deciding on the start and end dates to pick data out of a db. # Get the current time as the stop time. # stoptime=`date +"%Y-%m-%d %H:00"` if test $? -ne 0 then echo "Failed to get the date" rm -f $1/.optpamo.pid exit 4 fi # # Read the lasttime file to ...

How to handle non-printable ASCII character parameters?

I'm working on a project where we are dealing with importing/exporting data from database tables using ksh scripts and Perl scripts. We have an existing process to export data from a table to a file and it is then imported into another system. Here's the catch - the export process dumps out pipe delimited files while the system that is...

Deleting specific values from an array in ksh

I have a customized .profile that I use in ksh and below is a function that I created to skip back and forth from directories with overly complicated or long names. As you can see, the pathnames are stored in an array (BOOKMARKS[]) to keep track of them and reference them at a later time. I want to be able to delete certain values from ...

Regex in Korn Shell

I'm trying to check whether a variable is exactly 2 numbers but I can't seem to figure it out. How do you do check regular expressions in KSH? I've tried if [[ $month =~ "[0-9]{2}" ]] if [[ $month = _[0-9]{2}_ ]] I haven't been able to find any docs on it ...

Shell script to stop a java program

Is there a way to stop a java program running using a shell script by knowing the name alone.I am using ksh shell ...

ksh script spawns unwanted child with the same name

So.. I use KSH on Solaris8 for quite long but this is the first time I got something like this: I start a script - let's call it splitCfg. When I call pgrep -x splitCfg I'm finding two instances of this script - the main instance and a child of my script (output from ps): root 28069 25107 0 20:22:01 pts/10 0:00 splitCfg root 4668 2...

What is the korn typset option -t (tag) used for?

I was reading about the Korn typeset command and discovered the -t option adds a tag, but I can't figure out what it's used for. Does anyone have an example? -t Tags the name. Tags are user definable and have no special meaning to the shell. ...

Korn Shell SegFault

I have found the following script causes a segmentation fault and core in kshell on AIX. Can anyone explain why I get the following results? Seg Fault doOutput(){ Echo "Something" } doOutput() >&1 OR doOutput(){ Echo "Something" } echo `doOutput()` No Output doOutput(){ Echo "Something" } doOutput() Correct doOutp...

shell script to get the file name from a text

I need to get the name of the file (esrt-deghasdf-keystore) before .jks.I want to do it using shellscript.Is it possible? abcdefgh 7369 4825 0 00:12:26 pts/10 0:37 java -Djavax.net.ssl.keyStore=/abc3/esrt/der/fer-def2/esrt-deghasdf-keystore.jks ...

Tool to create a call diagram for Korn Shell?

Is there a tool available to create call diagrams or create other documentation from a Korn Shell file? ...

CVS branch name from tag name

I have a number of modules in CVS with different tags. How would I go about getting the name of the branch these tagged files exist on? I've tried checking out a file from the module using cvs co -r TAG and then doing cvs log but it appears to give me a list of all of the branches that the file exists on, rather than just a single branch...