Tag Info

New answers tagged

1

You're not totally right regarding the meaning the sed options. Let me first explain them then we will understand what your code is doing. Option -i means : instead of displaying the result of the sed processing on the terminal, write it to the file. s/ syntax is s/regexp/replacement/. It means sed will substitute the strings matching the regular ...


1

@Oli told you why it is probably failing so I'll just explain the sed code: sed -i "s/tk[0-9]*;/tk$company_id;/1i" The s/PATTERN/REPLACEMENT/FLAGS is the substitution operator. It will replace PATTERN with REPLACEMENT. The FLAGS (for example, g in s///g) can modify its behavior. Here, the flags are N (1 in your example) which means "Replace only the Nth ...


3

I have an update.sh file, which is run every night I read that as "I'm launching this via cron". A very common issue people have with cron is that they make expectations about the environment the script runs in. They assume the script will run in their home directory. That's exactly what you're doing. All your sed commands use relative paths so they ...


1

You can't delete history like this as it will delete the history of current session. If you wan to clear your history using script use following command in your script > ~/.bash_history It is enough to clear all your bash history .


0

I think that history -c will only clear the history inside the seesion associated with the script This example: #!/bin/bash HISTFILE=~/.bash_history # Or wherever you bash history file lives set -o history # enable history uname -a > /dev/null history history -c history shows the output: .... 500 history 501 uname -a > ...


4

Try: alias music='/home/robin/Dokumente/music.sh' the ./ part usually denotes current directory, so a relative path.


2

You don't know how to source a file (script). The right way is to use one of the following commands: source /etc/fls/5.0/fls.sh or . /etc/fls/5.0/fls.sh See also: What is the difference between "source x", ". x" and "./x" in Bash?


0

You (and me) started from the wrong assumption. According to this, [...] the messages are printed the console and written to usplash (if applicable). There's also this post on SO saying that you should rather use #!/bin/sh instead of bash (but failing to provide a reason for that). So even if there's no issue with using bash, you won't find something ...


0

don't start installation as a "oracle" user. Use sudo from your current desktop user or use root (without sudo). Than in your case oracle@sergio:/u01/app/oraInventory$ sudo sh orainstRoot.sh should be started from sergio user: sergio@sergio:/u01/app/oraInventory$ sudo sh ./orainstRoot.sh


1

This is another solution using awk: awk -F "\" '{print $(NF)}' testfile > outFile where -F define the input field separator, than print $(NF) print out the last field. outFile will contains: jsmith90 aakhbar91 pmanning92 dvader93 jshephard94 bwayne95


3

case in bash should end in esac, select should end in done. I don't see those keywords in your script. select NAME [in WORDS ... ;] do COMMANDS; done case WORD in [PATTERN [| PATTERN]...) COMMANDS ;;]... esac


2

Does this do what you expect? gnome-session-quit --power-off Alternatively there are some other options to gnome-session-quit.


3

The line with DROPBOX="/root/Dropbox/Backups does not have a " at the end. The MYSQL, MYSQLDUMP and GZIP variables refer to the programs used to execute various commands. So they should contain the path of those programs: MYSQL="/usr/bin/mysql" MYSQLDUMP="/usr/bin/mysqldump" GZIP="/bin/gzip" You can use the output of which <program name> to see ...


2

Though two correct answers have been given but I am giving my personal solution-- sed 's/randomcollege-nt\\//g' testfile Thank you,


2

First, be sure that the shebang is exactly as follow: #!/bin/bash Second, be sure that the script is executable using the following command in terminal: chmod +x /path/to/a.sh And third, you must to use the full path for the bash script, or in your case, you can use: $message=exec("$old/a.sh"); And, as an aside note, the following two commands from ...


0

You should edit /etc/profile file with root privilege. It is system-wide profile. Runs before ~/.profile


1

Have you tried using env to run the shell in a custom environment e.g. /usr/bin/env HISTIGNORE='*' /bin/bash from the gnome-terminal Title and Command tab? This seems to work for me - although I can't help feeling there's a more efficient way that doesn't involve testing each command against the wildcard.


3

You can get output simply by using command cut: cut -d '\' -f 2 < TestFile Where -d is used to determine delimiter which is / here and -f for selecting fields which is 2 here. Example: $ cat TestFile randomcollege-nt\jsmith90 randomcollege-nt\aakhbar91 randomcollege-nt\pmanning92 randomcollege-nt\dvader93 jshephard94 bwayne95 $ cut -d '\' -f 2 < ...


1

You have few options. One is to stop the script (CtrlZ), get the PID of the script and send SIGKILL to the process group. When a command is executed in a shell, the process it starts and all its children are part of the same process group (in this case, the foreground process group). To send a signal to all processes in this group, you send it to the ...


0

As Harris said you could run Kill -9 PID_Number but you could also install the package known as htop to have an interactive process browser that makes finding specific processes a lot easier. htop also supports killing processes.


6

You can use sed: sed -i~ 's/.*\\//' TestFile -i~ tells sed to create a backup with the ~ extension. s/// is substitution. .*\\ means anything (.*) followed by a backslash the replacement part is empty //, i.e. everything up to a backslash will be replaced by nothing.


1

If you know the processes that are associated with the script you can find their PID using ps -A and then use the PID number to kill the corresponding processes using kill -9 PID_Number


1

It seems that using tee to redirect to a file and paging stdout would be more appropriate than paging in the middle of a pipeline: printf "%s\n" this is a test | tee /tmp/some.file | more -3


1

I was able to do this using dconf e.g. to set the launcher icon size to 64 pixels Code: dconf write /org/compiz/profiles/unity/plugins/unityshell/icon-size 64 To reset it to the default value, you can use Code: dconf reset /org/compiz/profiles/unity/plugins/unityshell/icon-size The dconf command line utility is not installed by default - you need to ...


0

You can check JSWare which states being VBScript engine for Linux systems.


0

If you look at /etc/crontab, you'll see: 17 * * * * root cd / && run-parts --report /etc/cron.hourly 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 52 6 1 * * root ...


0

Another solution that I used is based on Upstart, a quite powerful stuff. Maybe you don't need it at all. http://upstart.ubuntu.com/cookbook/ Let's create a file in your home /home/your_user_name/scripts/my_script.conf with this content: # my_script.conf description "here goes the description for my_script" author "Peter Farkas @ InDaLine" # Stanzas # # ...


1

Considering your requirement of running a job when you login to Unity and not for other logins, an Upstart session job seems perfect. You may have noticed it: processes that you run after a GUI login are under a second init process. This init is a proper Upstart init, and you can start and stop session jobs based on events emitted by it. No root privileges ...


1

To get this working use the following: [Desktop Entry] Version=1.0 Type=Application Name=Play Comment=Play music Exec=bash /home/awesome/Desktop/test/play.sh Path=/home/awesome/Desktop/test/ Icon= Terminal=true GenericName=Player


0

Well, I've found a crazy workaround. So, I thought I'd share. I'm not expecting it to be the accepted answer, however (but it works). It may or may not be dangerous. That is to copy xfc4-session-settings from /usr/bin into the bin folder of all the users that I actually want to be able to use it (e.g. /home/sally/bin). Then, delete it from /usr/bin. Then, ...


0

As for your code: Do not put error messages to STDOUT, there is STDERR for them. Do not forget to enclose filenames (and veriables in general) in quotes. tar xjf $1 would not work if $1 contains spaces. gunzip and bunzip2 without -k (--keep) option delete compressed file after decomressing. Are you sure you want it? GNU tar can detect compression format by ...


0

Edited... I think you're looking for an 'init script' solution. There is a simple example here: http://unix.stackexchange.com/questions/6697/run-python-script-on-startup and another one here: http://mobiarch.wordpress.com/2014/05/16/creating-an-init-script-in-ubuntu-14-04/ Briefly: You put your script to e.g. /usr/local/bin/my_script.py (it's not ...


2

In awk, awk -F" : " '/^String/ {string = $2}; /^needed/ {print string, $0}' f1.txt You can do a similar thing in sed, although it's not quite so compact - basically it uses sed's hold space as the equivalent of the string variable. Unfortunately AFAIK there's no simple way to prepend the hold space to the pattern space in sed, so we have to append and ...


0

Here's an example script that does this: http://paste.ubuntu.com/8186522/ I have made a few assumptions: Your assignment is going to use : as the separator. I have taken advantage of this in setting the IFS for read. You don't mind going over the file multiple times. This can be done in one pass, in fact might be easier that way, depending on the ...


0

Here are some suggestions for running a script after login: StackOverflow Linux script after bootup: Cliff notes is to put your *.sh file in /etc/profile.d. If you want to run scripts upon bootup, here are some suggestions for that: StackOverflow Linux script after boot: Cliff notes is to use /etc/rc.local or crontab.


1

I had the same problem but was not very happy with the solutions here or the solutions did not work for me. What I found out to get it running is to send a NULL input to apt-get, so that it continues to work. It looks like this: apt-get -y install gcc g++ make cmake perl < "/dev/null" cd ~/ mkdir t1 cd t1 #newline Hope other people can use this ...


0

In my .bashrc, I define a function, screenshot to use ImageMagik: screenshot () { import -window root ~/var/screenshot/$(tshhmmss)_screendump.png } and, for the timestamp, alias tshhmmss='date +%y%b%d-%H%M%S' Then, wrapping it in while sleep 5 ... is easy.


1

Yes: #! /bin/bash while sleep 5 do shutter -f -o 'myshot-%T.jpg' -e done The sleep command can take various time durations as arguments: 5s (or just 5) for 5 seconds, 129m for 129 minutes, etc. The shutter command supports JPEG output, and the %T tells Shutter to automatically replace that part with the time of the script. (There's also %NN to ...


0

Use vimdiff... Normal syntax : vimdiff file1 file2


0

You could try to change synclient touchpadoff=0 to synclient touchpadon=1 and at right" styles rotate half and erase" rotate half. and it might work fine this way.


-1

Change the script to xrandr|grep " connected" |awk '{print $5}' as Charles suggested.


1

OK here is a real fix first open a terminal sudo gedit~/.bashrc Find this section and add a # to the line like in the code I pasted below, this will let you chane the names of terminals and your original code is fine. case "$TERM" in xterm*|rxvt*) # JEFFYEE REMOVED because it makes commands to title() not work ...


0

Use wmctrl -r :ACTIVE: -b toggle,above use toggle instead of add (reason : Source) For bottom right, i am working and will update this answer.


2

This sounds suspiciously like a homework assignment*, but here we go. Why would you source the ELABORATO.SH script? If you do and it has an exit statement or errors out, your TEST.SH does the same. I don't think that's what you want. I would just run the script: bash ELABORATO.SH param1 param2 Did you think about redirecting its input? bash ...


3

When you call the script, a new child shell is invoked to run it. Its proxies are set, but the proxy of the parent process (your shell) can't be changed from a child process. Try sourcing the script, i.e. call it like . setproxy 21 Then the script will be interpreted by your current shell.


1

How about while server-is-not-running; do try-and-start-server sleep seconds-to-wait done where server-is-not-running is your current test to see if the server is running, i.e. a shell function or an external command returning non-zero if the server is running (alternatively, ! server-is-running if that function or command returns zero if the ...


1

Just make an infinite while loop: #!/bin/sh while [ TRUE ]; do check_server_status 10.0.. etherwake ff:ff.. done


-1

Does the file exist and do you have read permissions on it. Is it executable, it's directory path needs to be executable. The commands ls -l and chmod will help. Secondly your terminology is a bit microsoft, sh files which execute more like .bat files and binaries which ms calls .exe.


1

Assuming you wish to run this script every time your machine boots, a convenient way is to add an upstart init task. Create a file my-startup-script.conf (its name is up to you, but it must have extension .conf) in /etc/init, containing the following: description "Describe what the script does." start on filesystem task script cd /path/to/script ...


1

Meld is a really great tool. But you can also use diffuse to visually compare two files: diffuse file1.txt file2.txt



Top 50 recent answers are included