Hot answers tagged

4

tmux \ new-session 'compass watch /path/to/project1/compass/' \; \ split-window 'compass watch /path/to/project2/compass/' \; \ detach-client The new-session command (which creates a new tmux session) and the split-window command (which splits the current window into two panes) in tmux takes optional shell commands to run. The detach-client ...


4

You can use Anacron for this, it is designed to run jobs at certain intervals without assuming that the system is on continuously. If a job is supposed to be run every month, Anacron will check whether it has run in the previous month, and run it if it hasn't (and remember that it doesn't need to run it again for another month). In Debian derivatives, ...


3

There's no way to tell for sure whether a file has been renamed. When a file is renamed, its inode number doesn't change. (This may not be true for “exotic” filesystems, such as network filesystems, but it's true for all “native” Unix filesystems.) However the converse is not true: if a file is deleted, a new file may be created with the same inode number. ...


3

There are two issues here. First, if you want to replace ; with \;, you need to escape the \. Remember that \ is a special character, it is used to escape things (which is, presumably, precisely why you want to add it before the ;). In order to use it literally, in a substitution, you need to escape it too: $ variable='1;2;3;4' $ echo "${variable//;/\;}" ##...


3

You can not modify the variable inside the for cycle like this in bash. Oh ... you can, but it will not affect the iterations. It is not counted loop as we can be used to from C. Minimal example: #!/bin/bash for i in {1..3} do echo $i i=$((i-1)) echo $i done obviously prints: ./b.sh 1 0 2 1 3 2 You would better be with standard loop with ...


3

dch is designed to work one comment at a time. When you're adding changes to the changelog, simply run dch -v ${RELEASE_VER} "comment" multiple times (the -v ${RELEASE_VER} part is only necessary the first time). This will build up a list of changes with a header targeting UNRELEASED; that's the marker dch uses to decide that it should add new comments to ...


2

# launch child process in background launch_child_process & # grab child's pid and store it (use array if several) pid=$! # later, wait for termination wait $pid # show return code from wait, which is actually the return code of the child echo "Child return code:" $? With several children, you can of course loop to wait on each pid and collect the ...


2

Yes, you can require both kerberos and public key authentication with AuthenticationMethods sshd option. man 5 sshd_config: AuthenticationMethods Specifies the authentication methods that must be successfully completed for a user to be granted access. This option must be followed by one or more comma-separated lists of authentication ...


2

The shell will perform word splitting on $(cat $Errors). That is why you get one word at a time instead of one line at a time. You want a while read... loop: while read -r line; do #Get Error Logs grep "$line" /home/eximlog >> $Elogs done <"$Errors" read is line oriented: it reads one line at a time. Or, this may work for you and it ...


2

You can use tac to reverse the lines of file and delete 3 lines before matching pattern including line which contains the matching pattern using sed, like this: tac filename | sed '/0 hits/I,+3 d' | tac and if you wanna edit file in place you can use -i option in sed command like, tac filename | sed -i '/0 hits/I,+3 d' filename | tac


2

You can do something like this: files=$( ls -l --time-style=+%D | grep $(date +%D) | grep -v '^d' | awk '{print $NF}' ) ; for f in $files ; do cp -rf $f /home/oracle/SABARISH/logs/files/ ; done ; sftp {user}@{host}:{remote_dir} <<< 'put /home/oracle/SABARISH/logs/files/*' or similarly: for f in $(ls -l --time-style=+%D | grep $(date +%D) | grep -...


2

That's a job for pax. pax is a standard POSIX command; some Linux distributions omit it from the default installation, so you may need to install the package explicitly. You don't get the full power of Perl, just basic sed regex replacement, but that's good enough for your use case. pax -rw -pe -s'|/pars/|/|' -s'|/fts/|/|' -s'|innobase/include|include|' … ...


2

A much more readable way to do this sort of this is with a case statement: move='' while [[ -z "$move" ]]; do echo "Please specify paper, scissors, or rock. >" read userinput case "$userinput" in [Rr]*) move="rock" ;; [Pp]*) move="paper" ;; [Ss]*) move="scissors" ;; *)...


2

Lets say your file is named just file. This script will do the job: USERNAME=$(cat file | cut -d: -f1) echo "$USERNAME" ID=$(cat file | cut -d: -f2) echo "$ID" USER_SHELL=$(cat file | cut -d, -f2 | cut -d: -f2) echo "$USER_SHELL" useradd -m -s "$USER_SHELL" -u "$ID" "$USERNAME"


2

You can use rsync command for this kind of operations. How to use rsync to sync with a remote system Syncing to a remote system is trivial if you have SSH access to the remote machine and rsync installed on both sides. You need to set up SSH keys, it's well described how to do it here: https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys-...


2

It seems fcron is the right tool: "fcron makes no assumptions on whether your system is running all the time or regularly : you can, for instance, tell fcron to execute tasks every x hours y minutes of system up time or to do a job only once in a specified interval of time."


2

I would use paste here. It's a nifty tool that can be used to combine files: $ paste printdirs.txt archivedirs.txt /u/lawson/law/print/lawson/tim/1 /u/lawson/law/print/archive /u/lawson/law/print/dgfinance/monday190/1 /u/lawson/law/print/archive2 As you can see above, it will print successive lines from both files, separated by tabs. The tab-...


1

$VARIABLE and ${VARIABLE} are effectively the same if they are standalone words. But notice the following example, especially in a script VARIABLE=USER echo $VARIABLE you get output USER but when you type echo $VARIABLE1 expecting to get USER1 you get nothing as there is no variable as VARIABLE1 defined But if you use echo ${VARIABLE}1 you ...


1

there are two problems here, one is finding proper terminal setting. I suggest using UTF-8. next try sed -e 's:\,:\&#44;:' -e 's/Décor/D\&eacute;cor/' VENKAT.TXT you can use multiple replacement using -e ... -e ... you can use any char as separator for find and replace, not just /


1

Unix philosophy: one tool does one thing (very well), then combine tools. I suggest that you use the tools you know. The tools that have all the features and options you need and know/master already. So, use cp, rsync, scp or whatever, then use your favorite rename command.


1

If you know N beforehand, you can use fifo as a semaphore. mkfifo sem; exec 3<>sem rm -f sem Then make each N>1 process read a byte from that &3. Since those bytes won't initially be available, it'll put them to sleep as well. Once N==1 is done sleeping, it can write a N bytes into &3, waking up each process that has been waiting on a byte ...


1

I recommend to use zsh shell for this job: cp *(m-1) /home/oracle/SABARISH/logs/files/ where (m-1) is so called glob qualifier. In this case we select all (*) files modified (m) within (-) last (1) day.


1

It looks to me as if you're being miserly with space characters. You need a space before the {}, and both before and after the \; and after the cp and 'lab4.bak'. You don't need single-quotes around the {} either. The second -exec ... should probably be -exec cp {}.bak /IFT383ss16/Labs/ \; Try this: find . -maxdepth 1 -type f -size +1k \ -exec gzip -...


1

From the bash help on select: select: select NAME [in WORDS ... ;] do COMMANDS; done ... COMMANDS are executed after each selection until a break command is executed The break command you do have in there is breaking the case, not the select. You need to put a break outside the case block. For example: echo "Do u want to check application logs ???...


1

Your first problem is that the block that is to be looped through by a for needs to have a do and done block around it: for f in `cat file` do ... done Your second problem is that the remainder of the loop body (the if statements will not be executed inside the ssh session on the target host(s). You'll have to somehow push the if statements to the ...


1

It is very complex to do this with sed. A more suitable tool is awk or bc. For example, to use bc add another sed to convert the input to a sequence of expressions (10/1) and strings (" ") separated by ";" or newline resulting in the following input for bc: 10/1;" "; 10/1;" "; 1099/100 "N \n" 10/1;" "; 10/1;" "; 1088/100 "E \n" bc will evaluate each ...


1

Using sed and date: sed -n "$(date +'%e')p" textfile.txt date +'%e' gives you the day of the month and this is used as an index for the line sed should print p. /edit: Worked in feedback from the comments.


1

I've solved the problem myself using the following solution: sed '/^10.*:/ s/$/ ON/' test_file.txt sed '/^10.*:/ s/$/ OFF/' test_file.txt


1

Did you try something? short example: while read line; do if [[ $line = \10.* ]] ; then echo "$line ON" else echo "$line OFF" fi done As a result: user@:~$ cat testo.txt 10.10.10.10 jsmith1234 [URL] 173.10.10.10 jsmith1234 [URL] user@:~$ bash testo.sh < testo.txt 10.10.10.10 jsmith1234 [URL] ON 173.10.10.10 jsmith1234 [...


1

Just remove all cases of IdentityFile and then add them again explicitly: $ perl -i -ne 'next if /IdentityFile/; s#YOURNAME#adminuser\nIdentityFile ~/.ssh/id_rsa#; print' file $ cat file User adminuser IdentityFile ~/.ssh/id_rsa . . . User adminuser IdentityFile ~/.ssh/id_rsa Installing Installing The next if /IdentityFile/ ...



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