Tag Info

New answers tagged

3

Not sure what you mean. Possibly with GNU grep: grep -Ero '(\\x[[:xdigit:]]{2})+' . To match strings of the format \xNN (the 4 characters backslash, x and two hexadecimal digits)


4

Try: #!/bin/bash id touch script-run-user.file sudo -u appuser 'ksh' <<EOF # add list of cmds to execute id touch appuser.file EOF Edit: Just as an update, check out Here Documents. EOF = "End Of File", the name is arbitrary.


0

If you had syntax errors in that script, you'd see them on stderr. ksh -n is the right thing. An example: $ cat script.ksh touch tmpfile for f in tmpfile # missing "do" rm $f done $ ksh script.ksh script.ksh: syntax error at line 3: `rm' unexpected $ ls -l tmp* -rw-rw-r-- 1 glennj glennj 0 Jul 22 06:54 tmpfile $ rm tmpfile $ ksh -n script.ksh ...


3

This is not a syntax error for actual ksh syntax, it's syntax error for invalid command name which only catched at run time. When you run it, you will get command not found error. If you add: echo foo ehco foo2 if [ 1 -lt 0 ] ...


1

The point of tail -f is to run forever until explicitly killed, so you'll have to arrange to kill it. If there is some logic that determines when the tail process is to be killed, obtain the process ID of tail and arrange to trigger its killing when desired. For example, if you want to kill it after a minute: tail -f file.log & tail_pid=$! sleep 60 ...


1

Start the command as a background task, with & at the end: nohup path_to_domain_bin/startWebLogic.sh>/dev/null < /dev/null 2>&1 & The output redirections are not helping much, as nohup redirects the output anyway, as you have noticed. To get rid of that, skip nohup and do what it does (rather, the essential part of it) in the script ...


4

If you don't background the tail command in your script, the shell will wait for it to exit, which will never happen. If you have other work to do, after which you want to kill the tail command, you can tail -f logfile & tailpid=$! ...do some other stuff... kill $tailpid ...carry on...


0

As I have posted in the other question, sometimes it is possible to get the file not found error even when you execute the script as ./scriptname. As I have posted in the other answer, you can test it in your machine. Testing cat ksh_experiment.ksh #!/usr/bin/ksh echo "Hello" Now after providing the permissions when I ran the file, it produced the ...


3

When you type a command, the shell looks up the command from a list of directories, as specified by the PATH variable. The current directory is not in PATH by default (for security reason), so the shell can not find your script. Using ./, meaning the current directory, so the shell knows where is your script.


6

Try "./a.sh" when trying to execute it. It needs to know where the file is at. The './' tells it to look in the current directory.


1

Let the read command to the splitting. read cmd arguments case $cmd in compile) … ;; esac


0

This should work in any POSIX-compliant shell: case $cmd in "compile ccms"|"compile asws") compile ;; *) break ;; esac


3

If you're using a sh-compatible shell (like bash), that > prompt is called the "secondary prompt". It's set by the value of the PS2 variable, just like PS1 sets the normal prompt. You should be able to change it to # pretty easily: PS2='# ' You might want to put that into your ~/.bashrc (or whatever the equivalent is for whatever shell you're using).


-1

-You try use this way!... /home/user> ls -ltra \\ file1.txt \\file2.txt ... This way you can get a better result! and another question what kind terminal you are using, bash, sh, csh ?...


2

It's not based on "the system". It's based on your shell. In bash or other Bourne shells PS2 The value of this parameter is expanded as with PS1 and used as the secondary prompt string. The default is ``> ''.


0

It's probably best in your example case to have sed quit the input file once you've found printed the data you desire. For instance: sed 1q <INPUT That will autoprint the first line and then end the process altogether. You can also do: head -n1 <INPUT ...to achieve the same effect. sed also interprets address,ranges though, and these can be ...


1

I am guessing this. I didn't try it myself. Let's see if it works. expect_ACTIVATE=`cat << EOF` set timeout -1 spawn $VPNC expect : {send Pass123\r} expect "\\$ " send "status=`echo $?\r`" expect eof EOF


1

Let your shell expand the variable by using " instead of '. Example: victor@pyfg:~$ line_number=2 victor@pyfg:~$ sed -n "${line_number},${line_number}p" /etc/hosts 1.2.3.4 row-2 Since you're only printing a single row, you can just to it like this also: victor@pyfg:~$ sed -n "${line_number}p" /etc/hosts 1.2.3.4 row-2


0

With relatively recent versions of ksh93: $ printf "%(%Y/%m/%d)T\n" "2014/06/20 +1 day" 2014/06/21 Or: $ printf "%(%Y/%m/%d)T\n" "2014/06/20 next day" 2014/06/21 $ printf "%(%Y/%m/%d)T\n" "2014/06/20 tomorrow" 2014/06/21



Top 50 recent answers are included