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

-1
votes
0answers
9 views

Adding a character to the end of a word

I have a text file that contains the names of students and I want to add to each student his rank attached to his name. Exple: for this file: Alin Robert Elisa Micheal i want to have this result: ...
0
votes
1answer
17 views

update-rc.d doesn't accept the header of a script file

I have beagleBoard and I want to start my script at boot time ( boot/reboot). So, i ran command: update-rc.d GatewayStart.sh defaults Output which says: header is rejected ...
1
vote
2answers
26 views

Where does the TERM environment variable default get set?

When I open a terminal window with the GNOME Terminal emulator in the desktop GUI the shell TERM environment variable defaults to the value xterm. If I use CTL+ALT+F1 to switch to a console TTY ...
0
votes
2answers
15 views

How to print arguments from a known element until an unknown element of an array with Bash

I am having a blonde moment. This is my data from myfile.csv 1429829254,e,SE,StckXchg,HDCU3000623,d,scan,253,47968,94,1420824420,JSSE-213,199,BS,KIT,*OUT* ...
2
votes
3answers
75 views

Is there a way of reading the last element of an array with bash?

If I have an array with 5 elements, for example: [a][b][c][d][e] Using echo ${myarray[4]} I can see what it holds. But what if I didn't know the number of elements in a given array? Is there a way ...
0
votes
0answers
17 views

tmux status bar path customization with sed

On the server I connnect to my home path is like this:/home/junk1/junk2/user. I can use the sed command pwd | sed -e 's|^/\([[:alnum:]]*\)/[[:alpha:]]*/[[:alpha:]]*|/\1|' to shorten the directory path ...
2
votes
2answers
38 views

Change color of input text, not output

I need to capture screenshots of the terminal where the typed commands visually "stand out" from the rest. Right now I'm using this to make my typed commands "red": PS1='\[\e[0;31m\]\u\[\e[m\] ...
-1
votes
0answers
37 views

Bash forward all the arguments (including quotes) [on hold]

In my bash script I need to call a java program with the exact argument as their inited n the script. For example ./test.sh -a "myfile.txt" -d "my regular expression" mydirectory The main problem ...
3
votes
2answers
248 views

Why I should avoid loops in shells? [duplicate]

The following link recommends against using loops in shells. bash variables in for loop range Why is this? Here is an example loop I just happened to be looking at when I came across that answer: ...
1
vote
0answers
16 views

Is there a way to make bash recognize aliases with prefixes [duplicate]

Assume you defined the alias alias grep='grep --color=auto' in ~/.bashrc. Then invoking sudo grep wouldn't trigger the alias to be used. Is there a way to do so? If yes, would that solution be ...
0
votes
1answer
28 views

Find all paths added to PATH [on hold]

I'm trying to uninstall some things from my system. I know that I can call them via the Terminal on Mac (bash) but I don't know where to find the files to remove them. I figured if there was some way ...
1
vote
2answers
47 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 = ...
2
votes
2answers
176 views

Why do I receive a “/bin/bash cannot find command” error for an alias?

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
25 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
1answer
20 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
217 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
36 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
36 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
51 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
41 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
31 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
30 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
29 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
103 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" ...
2
votes
1answer
35 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
19 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
316 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
34 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
51 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
23 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
36 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
52 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
53 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
19 views

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

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
63 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 [closed]

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
77 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
44 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
80 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 ...