Questions about bash only, as opposed to other Bourne/POSIX shells. For all Bourne/POSIX-style shells, use the /shell tag instead.

learn more… | top users | synonyms

0
votes
0answers
2 views

shell script to get collect pixel size of image

I'm trying to create shell script that returns the largest picture in total dimensions pixel size? for example: i have many directory over 7000+ , each directory have images dir_1/ picture_1.png ...
1
vote
0answers
19 views

How can I check if rsync made any changes in bash?

I have a script which uses rsync to sync data in a remote -> local scenario. Immediately after the rsync command is run, a check to see if the error code equals zero or not. If its zero, further ...
1
vote
2answers
70 views

why system tells me “/bin/bash cannot find command” when I add it to PATH?

I am using multiple python, I alias python3 to py: alias py="/opt/python3.4/bin/python3" I want to run python in vim so I write this: map <F9> :call SpecialCompileRun()<CR> func! ...
0
votes
1answer
16 views

Multiple input files and output files in awk

I have a folder full of text files named 000.txt to 181.txt. How can I process all of them with the same awk script (program.awk) and send them to their respective output files (output000.txt - ...
0
votes
0answers
12 views

Persistence Bash history between detached processes

I haven't yet been able to find this among the bash documentation so I was hoping it could get answered if I asked it here. Is there any way that I can, on execution of a script, branch its history ...
5
votes
3answers
211 views

Is it possible to echo into a file, but use indenting in the shell script source? [duplicate]

If I have some nested and indented statements that echo a multi-line string into a file, the indents from the original shell (in my case bash) will be carried over into the target file. To avoid ...
1
vote
1answer
18 views

Extracting duplicity backup data

I've made some backups of my previous systems using Deja Dup (duplicity). In my current distribution it's not available, so I've simply extracted the data. Now in order to make that data meaningful ...
3
votes
2answers
35 views

Remove data from the STDIN stream buffer of another TTY session

I encountered a problem the other day while running multiple tty sessions in separate terminal windows. I was running a expensive disk access command and was waiting for it to return. Meanwhile I was ...
1
vote
3answers
50 views

Last exit status from within script without source

Supposing someone invokes a non-existent command, the only way I know to retrieve its error status from a script I execute right after is by using source I.e., let's say this script's name is dummy ...
0
votes
0answers
40 views

Shell intervals using awk

I have a file a 10:10 10:30 b 12:15 13:15 c 16:54 17:54 and I need to enter interval for example 10:15 so my output should be a 10:10 10:30 How I need to do that using awk?
0
votes
1answer
23 views

Run script from GUI with terminal output

I would like to run a script from the GUI. For example a simple echo "hello" from the right click context menu. In my case I would set up an action in thunar like this: Then it appears in the ...
1
vote
2answers
27 views

Using sed to replace javascript code in multiple files

I need to replace an old google analytics code with the new universal tracking code in lots of static html files. The old code looks like this: _uacct = "UA-XXXXXX-X"; urchinTracker(); The new code ...
-1
votes
0answers
29 views

Shell script for electrum - how to add the seed? [on hold]

I use a diskless web server with a live cd and looking for a possibility to restore my electrum wallets automatically by a seed. I would like to implement a script that performs this task for me. so ...
1
vote
1answer
26 views

Get first/second file column

I have two for loops here for i in $(cat "firstFile.txt") do for j in $(cat "secondFile.txt") do if [ "$i" = "$j" ]; then echo $i[$2] # use first file second column ...
4
votes
1answer
102 views

Redirection to file does not work properly

I have here a bash script: #!/bin/bash TARGET_FILE=ping_result.txt # declare the target ip addresses declare -a ips=("XXX.XXX.XXX.XXX" "YYY.YYY.YYY.YYY") function print_and_log() { echo "$1" ...
0
votes
0answers
27 views

Using nice on bash (or other) subshell?

Say I'm working on a sluggish system and notice (say via top) that CPU usage is up around 100%, but I don't want to kill the process. If I want to do other work on the machine and just make that ...
0
votes
0answers
18 views

output in columns [duplicate]

i am trying to put my data after a snmp walk in a table this is my code: for i in `cat $Rep_Scripts/IP_ALU_LIST.txt | awk '{print}'` do read hostname ip <<< $(echo $i |sed 's/;/ /') ...
5
votes
3answers
314 views

Compare the heads of two files in bash

I can do diff filea fileb to see the difference between files. I can also do head -1 filea to see the first line of filea or fileb. How can I combine these commands to show the difference between the ...
2
votes
1answer
31 views

Expand variable in brace expansion [duplicate]

I am trying to enumerate a range of integers using a variable but having some trouble. When I type echo {1..5} I get 1 2 3 4 5 However, when I type a variable, I am unable to get the ...
2
votes
1answer
25 views

How to download a lot of documents on the terminal from a server?

I have to write a bash script (.sh) with less than 300 characters which downloads all of the genomes 22 in this server ftp://ftp.ncbi.nih.gov/genomes/Homo_sapiens/ (the ones with fa.gz extention) and ...
1
vote
3answers
45 views

bash: Saving aliases beyond one session

Recently, I've been fiddling around with Linux's terminal commands to try and get a better feel for the system. I was happy to know that I could give commands a different name in order to call them, ...
0
votes
1answer
22 views

need help with inserting variables in a file path on GNU linux (SLES 11)

I am tryin to insert 3 variables to build a path, but unable to get it . I am trying the below log_path="/vol02/logs/$dname/logs/103602_$msname/${msname}_start.log" dname=cfp msname=cfp003 i get ...
1
vote
1answer
35 views

How to wrap bash commands after adding color

My current .bash_profile is equal to the below. I add some color and add a command that outputs whether or not I am in a git repository to my PS1 for my bash profile. ORIG=$PS1 ...
1
vote
1answer
25 views

How use '(' token when using it for searching with ag / awk?

$ ag findVersions( src/java/com/google -bash: syntax error near unexpected token `(' I tried quoting it, escaping it, both were not suitable. $ ag findVersions\( src/java/com/google ERR: ...
-2
votes
2answers
51 views

Change file name in different path [duplicate]

I would like to know how to rename the same log file which is in different path. I mean, the log file is in /main/rel/1.2, /main/rel/1.3, /main/rel/1.4, /main/rel/1.5 etc. I want just do it from ...
1
vote
1answer
47 views

Redirect the output of a query in a file

How I can do to redirect the query result in a text file in sqlplus I tried: start requete.sql > resultat.txt but it dosen't work
2
votes
2answers
52 views

Joining bash arguments into single string with spaces

I'm trying to join all of the arguments to a Bash function into one single string with spaces separating each argument. I also need to have the string include single quotes around the whole string. ...
-3
votes
0answers
16 views

bypass Kali GNU/Linux 2.0~alpha1 kali tty1 [on hold]

how to bypass Kali GNU/Linux 2.0~alpha1 kali tty1, it happens after I updated my kali running the commands apt-get install update apt-get install dist-upgrade reboot
0
votes
0answers
44 views

Schedule backup with notification?

To avoid editing files at the same time of backup scheduled by cron, I figure out a way: Before backup, send a desktop notification such as notify-send -t 0 "Ready for backup", to let me prepare ...
1
vote
2answers
62 views

How to strip time stamps from a file?

I have log which contains lines of data: Mon Apr 20 03:15:18 EDT 2015: my|data|data|data I am trying to write a script which would extract just the data from the log, stripping the leading time ...
0
votes
0answers
20 views

Sed replace with command output [duplicate]

I'm trying to replace text with the contents of a file and I'm getting errors. This works: cat /tmp/test | sed -e "s/__TEST__/$(cat pass)/g" But this one doesn't cat /tmp/test | sed -e ...
0
votes
2answers
25 views

Exclude the output from ssh and only log the error if found

typeset -f | sshpass -e ssh -o StrictHostKeyChecking=no user@${IPADDRESS} " $(cat); IFERROR=$(checkscript); echo "$IFERROR"" > ${SSHTEMPFILE} 2>&1 This line...I can't exclude the ...
3
votes
1answer
39 views

Bash Environment Variable Issue [on hold]

We have a 3rd party scheduler that runs one of our job's shell scripts in bash. When the shell script is called, it sets the environment variables from the scheduler as $1, $2, $3, etc on the command ...
1
vote
2answers
51 views

Format Column Width with Printf

I have searched online for 10 hours now and tried various codes, but still need help. I am attempting to merge three files using 'paste' and 'awk'. However, the columns are not adjusting to the ...
1
vote
1answer
18 views

Dotfile not working in current shell, need new one

To be clear, this isn't a screen issue, I'm sure it's a general shell issue. On a new Ubuntu 12.04 server, I'm currently logged into a terminal in which I want to run the screen command with my ...
3
votes
3answers
75 views

Match lines of a file with headers in other to obtain entire para

I want help with scripting to work with two files, wherein file 1 lists amino acids which are in specific order (one below the other and also might repeat) and the second file 2 constitutes the ...
1
vote
1answer
43 views

Getting Python errors whenever I try to use terminal in Linux Mint

I've had Mint installed as a dual boot on my laptop for some time. I use it as my dev environment, for desktop and web related coding. I recently started getting errors which have rendered my terminal ...
4
votes
3answers
79 views

Adding vertical space after command in bash

How to add vertical space after each command in bash? Looking for a wee bit of vertical space, not a full line. 1/4 or 1/3 of the line height should do it. [edit] The space to add is only after the ...
1
vote
1answer
32 views

Variables in dialog radiolist

I have the following dialog radiolist, which works fine. #!/bin/bash ch1a="1" ch1b="Fri, 20/3/15" ch2a="2" ch2b="Sun, 21/6/15" ch1="\"$ch1a\" \"$ch1b\"" dialog --title "Equinoxes and Solistices" \ ...
3
votes
1answer
180 views

Linux: set command for local variables

I am trying to understand local/environment variables and export/set commands. $ set FILEM="razrax" $ echo $FILEM $ FILEN="test" $ echo $FILEN test Please explain why echo $FILEM returns empty ...
0
votes
1answer
42 views

bash cannot find mvn command after install

I tried to install Maven on CentOS 7, but afterwards typing mvn -version in the terminal results in bash: mvn: command not found.... How can I fix this so that I can call maven from the CentOS 7 ...
0
votes
0answers
22 views

RHEL Bash Script for Oracle WebLogic - Run command as another user; No such file or directory

I'm trying to run a test script which switches to a WebLogic 10.3.6 user and checks the status of the admin server. The script works fine when the variables are replaced with absolute paths, but this ...
1
vote
0answers
26 views

How to execute bash commands from C? [migrated]

Is there a way to run command line utilities, e.g. gzip, into a C app?
2
votes
1answer
33 views

Prevent glob expansion in foo=“*”; echo $foo [duplicate]

In Bash, when I do: foo="*" echo $foo It expands * to the contents of the current folder. How do I make sure it just prints a literal *? The same, by the way, happens with a regular echo "$foo", ...
2
votes
1answer
45 views

How to I prevent exec from keeping the script running?

I'm using exec like this: #!/bin/bash exec > >(tee /tmp/mylog.log) 2>&1 bash -c 'sleep 12312' & I want the output of the commands to be in a log file, and then I want to start a ...
0
votes
0answers
26 views

Command to see my current ip if proxy is applied only for a certain website

It might not be a relevent question here on so, but I tried on http://networkengineering.stackexchange.com and there are less users. So, I am not a networking guy and I have the next situation: I ...
1
vote
1answer
99 views

Listing functions defined in a “sourced” script?

I have a very simple bash script build.sh which defines - but doesn't invoke - a collection of functions, e.g. #! /bin/bash create_iptables_log() { # do stuff } apply_iptables_rules() { # ...
1
vote
0answers
39 views

changeshell -chsh (to zshell) asks for password often [closed]

I use ubuntu 14.04 in my Desktop. I switch to zsh using the command chsh -s /bin/zsh from .bashrc. And when i open a new shell prompt, it always asks for a password. When i do source .zshrc, it ...
1
vote
1answer
39 views

Combine 2 prompts into one, showing error condition in red/orange

Not a very interesting question, but the answer could be beneficial to a lot of users. ;-) As everyone, I have a customized prompt. Mine turns red for root and is green for a normal user and a few ...
0
votes
3answers
41 views

Bash: Access parameter passed to last command [duplicate]

This is a situation I often find myself in: mkdir /Some/really/long/path/to/a/directory/ cd /Some/really/long/path/to/a/directory/ I know that ideally you would cd /Some/...etc.../a/ and then mkdir ...