Tag Info

New answers tagged

0

sudo su -, which is a complicated way of writing sudo -i, constructs a pristine environment. That's the point of a login shell. Even a plain sudo removes most variables from the environment. Furthermore sudo is an external command; there's no way to elevate privileges in the shell script itself, only to run an external program (sudo) with extra privileges, ...


0

Inside the backticks, a backslash quotes the next character. So you're getting the output from the command ssh -q ${SIDHost} ". /usr/vmmc/bin/oracle_scripts/useq $ThisSID; echo $HOST_IS_ERPDB" You need \\ instead: ERPTest=`ssh -q ${SIDHost} ". /usr/vmmc/bin/oracle_scripts/useq $ThisSID; echo \\$HOST_IS_ERPDB"` so that ERPTest is set to the output of ...


-1

This doesn't work because the function log_f is not declared in the sudo su - shell you launch. Instead: extVAR="yourName" sudo su - <user> << EOF log_f() { echo "LOG line: $@" } intVAR=$(date) log_f ${intVAR} ${extVAR} EOF You need to get the function defined in the root subshell. That might do it, but.... I don't know what most of ...


4

Not only does ksh use sfio but it uses its own custom memory allocator. Nevertheless, my guess is sfio makes the difference in this case. I just tried to run your example under strace and can see that ksh calls read/write ~200 times (65 KB blocks) while sed does it ~3400 times (4 KB blocks). With sed -u my laptop almost melted, reads are done per byte and ...


1

SCRIPT_1="ksh -x script1.sh & bg_pid=$!; ksh -x script2.sh; wait $bg_pid"; SCRIPT_2="ksh -x script3.sh & bg_pid=$!; ksh -x script4.sh; wait $bg_pid"; eval $SCRIPT_1; sleep 20s; eval $SCRIPT_2;


0

I don't think diff (even in combination with cut) will be flexible enough to handle this. And it seems as though what you really want is keys in file1 that are not in file2 and vice versa - not strictly a line-by-line diff. If the input files are big, I would go with perl, but for small files this awk script works for the input provided: %cat a.awk BEGIN ...


3

awk is a better tool for comparing columns of files. See, for example, the answer to: compare two columns of different files and print if it matches -- there are similar answers out there for printing lines for matching columns. Since you want to print lines that don't match, we can create an awk command that prints the lines in file2 for which column 2 has ...


1

Since it looks like you don't have the ability to customize your .profile but you can write to /tmp then you could do the following: Put all your customizations into a shell script (e.g. $HOME/myCustomizations.sh) on your local server. Something like this: alias ls='ls -laht' export AN_ENVIRONMENTAL_VAR_I_NEED_SET=VALUE scp $HOME/myCustomizations.sh ...


1

There is an alternative for this question. First set vi mode for ksh: $ set -o vi After, you can use the Tab key this way. Example: You want complete the next path: $ cd /usr/local/s Type Tab key twice and You will see this: $ cd /usr/local/s 1) sbin/ 2) share/ 3) src/ Assuming you want to option 2 (/usr/local/share/ folder), type 2 Tab (2 key ...


0

If the values are in Unix seconds: date -u -d "0 $EndTime seconds - $StartTime seconds" +"%H:%M:%S" If not, convert them: start_time=06:07:25 end_time=07:02:08 StartTime=$(date -u -d "1970-1-1 $start_time" +"%s") FinalTime=$(date -u -d "1970-1-1 $end_time" +"%s") date -u -d "1970-1-1 $FinalTime sec - $StartTime sec" +"diff_time= %s seconds" For more ...


0

With GNU sed : sed -r 's/\b(from|group)\b/\n\1/g' file


4

When a user invokes sudo -l it lists what sudo will allow them to do, so you could have a script ran as root that bumps through /etc/passwd and sudo's to each user, invoke the sudo -l, directing the output to /tmp/${USER}_sudo_i_can_do.txt But if you don't have root access, you won't be able to do what you want to do; the list of permissions is readable ...


1

As OP said his first line or word of file can be contains any word(like PPP itself), so you need to check that and scape the first line from matching and avoid the awk to exit there. Then you can try this: Input file: PPP # the first line/word chuld be any word !!!!! ) BBB $$$ JJJ OOO PPP 345 PPP %%% Command: awk '1;/PPP/{if (NR>1) exit}' file ...


1

Alternatively use a range pattern matching the first line (NR equal to 1) until the first match of 'PPP' in a line awk 'NR==1,/PPP/' file if the line must exactly match 'PPP' only use awk 'NR==1,/^PPP$/' file If you would like to do the same for each file in the argument list, use the FNR variable which resets to 1 for the first line of each processed ...


4

Try: $ awk '1;/PPP/{exit}' file AAA BBB JJJ OOO 345 211 BBB OOO OOO PPP



Top 50 recent answers are included