ksh

compare contents of two directories on remote server using unix

梦想的初衷 提交于 2019-11-27 09:22:07
问题 I am new to unix and need some help here. I have two directories present on two different server. both the directories contains the same files. Now i want to check if all files are in sync in both the directories. If files are not in sync then i want to display only name of those files. I am able to do it when directories are on same server. not able to figure out how to do this when directories are present on two different servers. eg: server1 /abc/home/sample1/ server2 /abc/home/sample2/

What does it mean in shell when we put a command inside dollar sign and parentheses: $(command)

只愿长相守 提交于 2019-11-27 06:51:21
I just want to understand following line of code in shell. It is used to get the current working directory. I am aware that $(variable) name return the value inside the variable name, but what is $(command) supposed to return? Does it return the value after executing the command? In that case, we can use ` to execute the command. CWD="$(cd "$(dirname $0)"; pwd)" Same output can be taken from the following line of code also in different version of shell DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" I am unable to understand the meaning of $(cd.. and $(dirname . Could anybody help me

how to merge two files consistently line by line

空扰寡人 提交于 2019-11-27 06:26:49
I have two files ( file1.txt & file2.txt ) , files are only examples . How to merge the two files , in order to create the file - merge_files.txt as example 3 I writing now ksh script , so merge can be done with ksh,awk,sed,perl one liner ...etc Background - why I need to merge the files : my target is to rename the OLD file (exist in first field) to NEW file (exist in second field) , example1 more file1.txt /etc/port1-192.9.200.1-255.555.255.0 /etc/port2-192.9.200.1-255.555.255.0 /etc/port3-192.9.200.1-255.555.255.0 /etc/port4-192.9.200.1-255.555.255.0 /etc/port5-192.9.200.1-255.555.255.0 . .

Reading file line by line (with space) in Unix Shell scripting - Issue

瘦欲@ 提交于 2019-11-27 05:41:03
问题 I want to read a file line by line in Unix shell scripting. Line can contain leading and trailing spaces and i want to read those spaces also in the line. I tried with "while read line" but read command is removing space characters from line :( Example if line in file are:- abcd efghijk abcdefg hijk line should be read as:- 1) "abcd efghijk" 2) " abcdefg hijk" What I tried is this (which not worked):- while read line do echo $line done < file.txt I want line including space and tab characters

How do I capture a SQLPlus exit code within a shell script?

青春壹個敷衍的年華 提交于 2019-11-27 03:28:22
问题 I have a KornShell (ksh) script that logins into SQL*Plus and executing a script. Within the shell script I would like to capture the status code of the SQL statement that was executed. Currently there is an error with SQL and I am unable to capture it by checking $?. How would I capture the success or error code from the sql statement and pass it to the shell script. Snippet of ksh script: sqlplus $JDBC_FBUID_U/$JDBC_FBPWD_U@$JDBC_FBDB @${FBC_HOME}/FBCS003.sql ${outputfile} if [ $? != 0 ]

ksh88 changing single quotes to double quotes inside heredocs?

不问归期 提交于 2019-11-27 03:26:24
问题 I seem to be running into an issue that's specific to ksh88 that's changing single quotes to double quotes, but only under certain situations involving heredocs and command substitution. Here's an example: #!/bin/ksh # This example works correctly echo "Example 1:" cat <<EOF The 'quick' brown fox "jumped" over the lazy dog. EOF echo # This example is broken echo "Example 2:" var=$(cat <<EOF The 'quick' brown fox "jumped" over the lazy dog. EOF) echo "${var}" echo # This example works

File execution with dot space versus dot slash

倾然丶 夕夏残阳落幕 提交于 2019-11-27 00:45:28
问题 I am attempting to work with an existing library of code but have encountered an issue. In short, I execute a shell script (let's call this one A ) whose first act is to call another script ( B ). Script B is in my current directory (a requirement of the program I'm using). The software's manual makes reference to bash , however comments in A suggest it was developed in ksh . I've been operating in bash so far. Inside A , the line to execute B is simply: . B It uses the "dot space" syntax to

redirect command output into variable and standard output in ksh

ε祈祈猫儿з 提交于 2019-11-26 22:56:47
问题 I have some shell command. I would like to write the output to the standard output and save it into variable as well. I'd like to solve it with one command. I have tried these things. ls > $VAR # redirects the output to file which name is stored in $VAR ls | tee -a $VAR # writes to standard output as well as in file which name is stored in $VAR VAR=`ls` # output into $VAR, but it is not sent to standard output VAR=`ls`;echo $VAR # ok, it works but these are two commands Any idea? 回答1: How

In a unix shell, how to get yesterday's date into a variable?

有些话、适合烂在心里 提交于 2019-11-26 22:43:01
问题 I've got a shell script which does the following to store the current day's date in a variable 'dt': date "+%a %d/%m/%Y" | read dt echo ${dt} How would i go about getting yesterdays date into a variable? Basically what i'm trying to achieve is to use grep to pull all of yesterday's lines from a log file, since each line in the log contains the date in "Mon 01/02/2010" format. Thanks a lot 回答1: If you have Perl available (and your date doesn't have nice features like yesterday ), you can use:

Why doesn't **sort** sort the same on every machine?

喜夏-厌秋 提交于 2019-11-26 22:01:06
问题 Using the same sort command with the same input produces different results on different machines. How do I fix that? 回答1: The man-page on OS X says: ******* WARNING ******* The locale specified by the environment affects sort order. Set LC_ALL=C to get the traditional sort order that uses native byte values. which might explain things. If some of your systems have no locale support, they would default to that locale (C), so you wouldn't have to set it on those. If you have some that supports