1
vote
2answers
16 views

How to stop shell script if curl failed

I have script that used curl when i pass wrong parameters to script curl failed but script continue executing. I have tried use curl -f/--fail parameter but problem does not solved. What is the best ...
0
votes
2answers
21 views

Bash : conditionally moving nested duplicate directories

Assume I have a directory named "foo" that contains several directories: foo/bar/bar/(files) foo/bat/bat/(files) foo/baz/qux/(files) Is there a way to conditionally move the 'deepest' directory up ...
0
votes
0answers
12 views

stdbuf not working while unbuffer does

I am trying to apply timestamps to stdout of a process. For the proper timestamps to be applied, I attempt to unbuffer stdout of the process. This works with unbuffer but not with stdbuf as I would ...
0
votes
0answers
7 views

Unbuffer swallows the exit status of killed process

The expect "unbuffer" command seems to swallow the exit status of its child if the process is killed. Is there something that can be done to stop this behavior? It does not swallow the exit status if ...
0
votes
1answer
5 views

How to check core dump enabledness status in bash?

$ ulimit unlimited $ sleep 2 && killall -SEGV cat & [1] 11358 $ cat Segmentation fault $ ulimit -c unlimited $ ulimit unlimited $ sleep 2 && killall -SEGV cat & [1] 11462 $ cat ...
0
votes
2answers
21 views

File sorting confusion

Q1. I have a command and I'm confused why it's sorting the filesizes by Kilobytes then Megabytes? $ find ~ -maxdepth 1 -size +1024c -type f -exec du -h {} \; | sort -nr 80K /home/sl6/S3401636/Lab 4- ...
0
votes
1answer
34 views

Change user AND environment in bash script

Why does this work (as root): $su - aba ~> echo $JAVA_HOME Ausgabe: /usr/java/jdk1.7.0_45 And not this shell script (also run as root): #!/bin/bash su - aba << EOF echo $JAVA_HOME > ...
1
vote
0answers
27 views

IDE for Bash shell scripting on Ubuntu?

I'm probably looking for the Holy Grail here, but I figured I'd ask. Is there an IDE for Bash shell scripting on Ubuntu (Ubuntu 12.04 in my case)? Something with a code editor that lets you set ...
1
vote
3answers
58 views

Can anyone explain why this pattern matching is not working using sed

Trying to print out specific times of logs based on recommendation from this thread from super user. I am not sure why my patterns are not being matched by sed. I have the sample date and time I am ...
1
vote
1answer
46 views

Matching only numbers that come in numerical order

I have numbers in [.] indicating the page number of an orginal printed document I am transcribing. However, the document also contains other numbers in [.] that do not correspond to page numbers. For ...
-1
votes
0answers
19 views

Move a dir which contains compiled apps

I want to move a dir e.g. file_download to myappDir. I know I can do this via mvcommand. The main problem I have are compiled apps within my dir file_download. And after compile has been finished I ...
0
votes
1answer
29 views

Running a script from ssh, logging out and continuing the script

The overall question here is - how do I automate sshing into a machine, running a script, and exiting without killing the script? I know that this has been answered several times, but I'm not having ...
-1
votes
2answers
31 views

Unable to boot Windows 8 after an interrupted Ubuntu installation attempt

I have a Sony Vaio notebook with Windows 8(UEFI) installed,after trying to install Ubuntu 12.04 LTS(I cancelled the installation and restarted the pc) from a usb sticky,every time i turn on the ...
0
votes
0answers
11 views

Script to open mutliple terminals with multiple tabs each, move and resize these and execute commands

So I am trying to make a bashscript, which does the above mentioned. Background is that I have to keep an eye on lots of logs, and theres have to have opened many console side-by-side. E.g. one ...
0
votes
3answers
41 views

Grep for block surrounding an error message

I want to grep for the block of logs around a particular error message. Say I know my log looks like this: [----] I, [2014-04-10T19:12:36.294512 #1910:e93004] INFO -- : Started GET "/ems_infra/new" ...
0
votes
1answer
29 views

Bash alias with Sed not working

Does anyone know why this alias isn't working? alias tailsed="tailf error.log | sed -e 's/\\n/\n/g' -e 's/\\t/''/g'" I've tried replacing the single quotes with doubles so that it's like: alias ...
0
votes
1answer
27 views

how to give argument to multiple parameter calling bash

I know the title isn't very clear, but I don't really know how to state my problem. I have a shell, and I want to be able to call it using multiple parameters, some needing argument other not. ...
0
votes
1answer
25 views

How to print process id into statment

I have assigned a work to take take all process and make them into a statement. So I tried this script. #!/bin/bash a= ps | awk '{print $1}' echo select $a So I am getting this output PID 1838 ...
0
votes
0answers
24 views

configuring p4 on red hat enterprise linux

It's time to get rid of this simple but yet not easily explained topic. And whatever I got on internet, in one or other way, failed to sync my WINDOWS depot to RHEL client. Following is the stuff I ...
0
votes
1answer
20 views

Entering Password in su- through loop

The Scenario is like I have a list of root passwords. But i don't want to keep trying Manually. So i wrote the shell script : for i in {1..26} do su - >>result done and all my ...
1
vote
1answer
21 views

How do I identify shell script execution vs dot execution

I'm writing a bash script that needs to run on the current process for it to be useful. That is, I want to make sure that the script was invoked with source script.sh or . ./script.sh and not ...
0
votes
0answers
19 views

Kali Linux: Renaming files in bin

I'm just curious. I want to rename files in /bin such as - ls --> als //after I change it, the ls command no longer works and I have to use als instead - adduser --> aadduser - chmod --> achmod so I ...
0
votes
1answer
30 views

How to use cd to locate a file and then open the file in vim easily in least possible keystrokes?

Very often I find myself in a situation where I would cd into a really deep directory structure to traverse to a file and then would have to open the file in vim.. So while doing cd I constantly keep ...
1
vote
2answers
32 views

Change range of bytes by address in pipe

I've got some binary data that is streaming through a bash pipeline. The data is usually more than 50MB in size. The existing code looks roughly like this inputprocess | filter1 | filter2 | filter3 ...
21
votes
2answers
836 views

How to create a directory named '-p' under Linux with Bash? [duplicate]

In Bash, how could I create a directory named -p? mkdir -p failed. mkdir "-p" failed. mkdir "\-p" failed. mkdir \-p failed.
0
votes
1answer
24 views

How to take screenshot(using selection) in awesome wm via scrot

Tried: awful.util.spawn("scrot -s") awful.util.spawn("urxvt -e \"scrot -s\"") os.execute("scrot -s") and all possible combinations even with sleep. Also tried daemonize. Nothing works =( P.S. All ...
0
votes
3answers
26 views

sed rename files moving numbers to end of file

I have a directory that contains several files with the following pattern. 1953-MADAMA BUTTERFLY 1953-MADAMA BUTTERFLY_001 I'm trying to bath rename them to achieve the following: MADAMA ...
1
vote
1answer
61 views

Linux Bash “|” operator doesn't work - what am I doing wrong?

I am trying to check user password via login command like this: #echo "name\npassword" | login but the command ends without writing anything. Echo ends because of SIGPIPE. Why did login stop ...
0
votes
1answer
26 views

Read-only bash traps

Assume the Linux root sets a trap on some signal in /etc/bash.bashrc, say: trap 'rm -f ~/tmpfile' EXIT root does not want any other user to mess up with this trap. So, he wants to make the trap ...
0
votes
3answers
33 views

Fast extraction of key-value pairs in Linux command-line

I have a large (tens of GBs) text file with data in key=value;foo=bar;baz=quo format. The number and order of keys can change from line to line. I need to process this file and extract values for ...
118
votes
9answers
12k views

I accidentally typed password into bash command line

I accidentally typed my password into bash command line, mistaking the Last login: ... line for Wrong password (I was in a hurry). What do I do to cover my trace? What I did was editing .bash_history ...
0
votes
2answers
47 views

Redirect two stdout to one stdin in Linux bash

I've got a C program that reads from stdin and does some operations. I am asked to enter information periodically (every 20 sec), and leave the user interaction the same while doing some tests. Is ...
1
vote
2answers
31 views

How to use a space in date format section of annotate-output?

I try to use annotate-output (part of devscripts package), to prefix outputs of a script with date and some extra info. First parameter can be a format string passed to date. I want to include a space ...
0
votes
1answer
42 views

Automated sudo and screen command

I would like to be able to launch a script in a separate screen command session as a separate user when I run a .sh script. Here is what I think it may be in the script: #I am also starting xampp ...
0
votes
0answers
34 views

Why do python's os.stat and du and ls not agree on block size?

While writing a simple function that computes the quantity of blocks consumed in a directory, I checked with du to see that I was getting the same answers. Why do ls and du say this file occupies ...
1
vote
3answers
89 views

How to launch a bash script in another one?

I'm trying to launch a script bash in another one... Here is my first script test.sh #!/bin/bash echo "test.sh" $1 $2 $3 >>/home/pi/test.log sudo ./temp.sh "$1" "$2" "$3" ...
0
votes
1answer
30 views

Difference of `route` and `ip route`

I'm using arch-linux. route and ip route give basically the same information to me. But route takes much more time than ip route. What is the reason?
0
votes
1answer
40 views

Better setting of EDITOR environment variable to use Sublime Text 2 as system editor?

I want to use Sublime Text 2 for editing Git commit messages. Right now I have the following in my bash rc file: export EDITOR="sublime -nw" This works well if Sublime is already running. But if ...
1
vote
1answer
24 views

Are upstart jobs guaranteed to be given time to run?

I am writing an upstart job that runs a shell script at startup and shutdown which synchronizes some files with a remote machine using rsync. The script can sometimes take a long time to complete if ...
0
votes
1answer
55 views

Way of identifying plaintext file types in bash?

Is there any alternative to the file command that can be used to identify plaintext file types that don't have a magic number? E.g. something I can give a file to that contains JSON and I'll get back ...
0
votes
1answer
20 views

SQLPLUS 32-bit Linux Pathing Issue

I am running linux 32 bit and installed Oracle 11g in it. I am trying to start sqlplus from command line but get the command not found error. I checked the environment variables and have ...
1
vote
1answer
35 views

How to get bash to automatically refresh program locations' cache?

I am aware of the bash internal command hash and how one can use hash -d or hash -r to forget remembered locations. Is there a way to instruct bash to automatically do this whenever it gets a "cache ...
0
votes
1answer
70 views

How do you run a command as another user on Linux?

I have access to a linux server where I can sudo to 'foo' like this without a password: sudo su - foo Once I am the 'foo' user I am able to run a script like this: /dir/foo_user_script.sh The ...
0
votes
1answer
20 views

Use of crontab, kill and trap

I'm learning crontab command, and I'm doing some tries. I edited the default crontab file with the command crontab -e, and I want to put a line that every minute send a SIGUSR1 to the current shell ...
1
vote
4answers
41 views

Skip parameter in Linux bash

I need to write a shell-script which handles 3 parameters ($1 $2 and $3). Within the bash I have to skip parameter 2 (I'm actually writing something like ./script.sh para1 para3). The script is OK. ...
1
vote
1answer
26 views

Upstart script that displays errors to the console?

I have a simple upstart script that runs a process and respawns it if it crashes. The problem is if it crashes I want the user to be alerted that it crashed (because they may need to take an action to ...
2
votes
1answer
35 views

Bash: Need to export variables to parent process. Is the parent the same process?

I'd like to launch a script that sets and/or updates some environment variables. Unlike this question, I don't mind launching the script as . /path/to/my/script/myScript.sh to force the script to ...
1
vote
1answer
26 views

Linux Unzip with exclusions from .txt file

I have an unzipping script on Linux. It attempts to unzip with the command: unzip file.zip This is obviously successful. I now wish to exclude some files. The manual tells me of the -x option. I ...
0
votes
3answers
31 views

Running BASH Script on a Remote Windows Machine from Linux Machine

I am planning to run a BASH script on a remote Windows system from my local Linux machine. For this purpose, I will have to login to Windows machine from the local one and then execute the BASH ...
0
votes
1answer
37 views

How to name a process for command and kill it later by name?

I need to make a short aux bash script to clear the logcat buffer and output afterwards in a file (new process). The problem is that at every run I need to kill the previous process which dumps in ...