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
12 views

Environment Variable not Exporting [duplicate]

I have this script that I'm writing, basically as my own free dynamic dns system (with a bit more manual-ness at the moment). Here it is: #!/bin/bash ...
0
votes
1answer
19 views

sort process by cpu usage in cygwin

please help me to sort process by cpu usage in cygwin. I already tried tasklist but it shows only process by memory usage .
3
votes
2answers
33 views

process Count of each user in ps aux command

How can i create a script to count process run by each user in ps aux. I used this ps aux | awk '{print $1}' | grep root | wc -l but it lists count of root user only . I want to list number of ...
1
vote
1answer
24 views

Can I uncompress a zip file containing a disk image and then save that to an SD card all in one step?

I am under the following restrictions: I have a 1.0 GB .zip file on my computer which contains one file, a disk image of raspbian. When uncompressed, this file is 3.2 GB large and named ...
1
vote
0answers
14 views

Why does history not overwrite but append when histappend is set to off in Bash?

Several days ago, I had one Terminal tab doing ssh, and the other doing a lot of work locally. And then I restarted the machine (on a Mac with Mavericks). When I ran Terminal again, I found that all ...
17
votes
2answers
396 views

What does 'exec {fd}</dev/watchdog' do in Bash

That is literal, {fd} isnt a placeholder. I have a script that does this, and does not source in anything, nor does it reference {fd} anywhere else. Is this valid bash? exec {fd}</dev/watchdog
2
votes
5answers
269 views

Get very next word of a substring in a string

I need to get the next word of a word in a string. I tried to write a script but it's not working. And it's good if you suggest me any other alternatives to achieve this. Script: #!/bin/bash ...
1
vote
3answers
33 views

Select and sort IP address keeping the whole line

So I need to sort the IP Addresses and then sort my line by them. I can sort IP addres in a file by using : sort -n -t . -k1,1 -k2,2 -k 3,3 -k4,4 If my file looks like : add method1 a.b.c.d ...
0
votes
2answers
35 views

Different behaviour of eval “ command \”$@\“ ”, “$@”, and “$(echo $@)” when used as arguments [duplicate]

I would like to pass multiple arguments to the Tor browser (firefox) programatically through a function arbitrarily entitled tor. This is so as to command tor search terms and voila! My search terms. ...
-3
votes
1answer
40 views

How can i replace a specific string within a line inside a text file [duplicate]

$ cat text.txt my name is Steven my age is 10 i like dogs What command will be fitting so that echo "Kate" will replace Steven on text.txt?
10
votes
1answer
113 views

Fastest way to delete duplicates in large wordlist?

I need to deduplicate a large wordlist. I tried several commands and did some research here and here where they explain that the fastest way to deduplicate a wordlist seems to be using awk. awk ...
4
votes
4answers
333 views

$@ except the 1st argument

I need to write a shell script that runs in this way: ./myscript arg1 arg2_1 arg2_2 arg2_3 ....... arg2_# there is a for loop inside script for i in $@ However, as I know, $@ includes $1 up to ...
3
votes
1answer
75 views

weird characters in bash shell

Sometimes when I use the rm tool or stat tool in bash shell I get following weird characters: root@server:~# rm -vr blah removed directory: �blah� root@server:~# Locale settings can be seen here: ...
0
votes
2answers
32 views

Insert text to file using bash scripts (NOT appending)

I want to add text to a file using shell-scripts. The solution I know is if you want to insert your text into a newline (appending): echo "mytext" >> myfile.txt what I want to have a ...
2
votes
2answers
31 views

How can I send multiple options to one variable

I am running a loop for an array of variables that generates three more variables. i.e for foo in ${bar[@]}; do bar1=$(echo $foo | awk '{print$1}'); bar2=$(echo $foo | awk '{print$2}'); ...
2
votes
2answers
42 views

List transient files by numerical value having number greater than a given constantly varying filename

I've a directory having constantly changing filenames (by numerical value) listed as: -rw-rw----. 1 root root 10493952 May 7 10:39 A0000000.LOG -rw-rw----. 1 root root 10493952 May 7 08:38 ...
1
vote
1answer
24 views

Starting in normal mode on bash

I was very happy to discover that I could use vi keybindings in the bash shell (bash vi mode). I am a little frustrated now however that the shell always defaults to insert mode rather than normal ...
1
vote
5answers
104 views

lines to columns with awk

I have to following sample output: <HARDWARE> <NAME>WIN1</NAME> <OS>Windows 7</OS> <IP>1.2.3.4</IP> <DOMAIN>contoso.com</DOMAIN> ...
0
votes
1answer
35 views

How to add a folder to a remote hosts PATH using a shell script?

I'd like to automate the process of syncing a local ~/bin folder to a remote host, and adding that folder to my remote shell's path. I've got the syncing part done, but am not sure how to automate ...
0
votes
1answer
34 views

How to add new column, where the value is based on existing columns with awk

I have a file of multiple columns. I would like to make an additional column based on the values of 2 columns from this file. Example input: A B C D E F 1 2 T TACA A 3 2 3 4 I R 8 2 9 3 A C 9 3 ...
3
votes
1answer
148 views

Exit bash when find gets to a folder with permission denied

I'm trying to write my second Bash script. Where i go through folders recursively and make a list of and count files and folders. In a way it works but if "find" gets to a directory where it has ...
1
vote
1answer
18 views

adb pull not accepting a variable as source, gives *' does not exist..* error

I'm trying to use $EXTERNAL_STORAGE in the adb pull command. I noticed that the variable has its scope defined in Android only and so it would not work successfully in adb pull ...
3
votes
0answers
67 views

How to best track adventures of a novice administrator

I have this user that has limited sudo privileges, yet he manages to screw up from time to time. I would like to keep an eye on his adventures, so that I can reverse any damage with less digging. ...
0
votes
3answers
48 views

How to execute source command from sh file

I have file called install.sh and within this file I write something to $HOME/.bashrc file and after that I must call source command. In terminal I can type source $HOME/.bashrc but I can't do this in ...
1
vote
1answer
6 views

Outputting PID of Rails server(s) with ps aux | grep - breaks when put into an alias?

I'm trying to create an alias for an unwieldy command I'm using to output the PID and some other information about two rails servers I have running. When I simply run the command in terminal (over ...
1
vote
1answer
36 views

Identifying duplicate fields and print both with awk

I have a file with multiple columns and want to identify those where specific column values (cols 3-6) have been duplicated. The following code finds the duplicates but I want to display both ...
0
votes
2answers
37 views

How to store whole a paragraph as one element of array in bash script

I am using the following code to read data from a file abcd.txt and try to store in an array parameters, I am able to store 619617 in parameter[0] and update in parameters[1] but in parameters[2] I am ...
1
vote
0answers
32 views

Debian Jessie, copy file on NFS share (autofs) at shutdown

I'm on Jessie 8.1 so I use systemd to launch a service at shutdown. My service uses a script to copy a file on a NFS share (mounted by autofs). It doesn't work, I know the script can copy a file on ...
0
votes
2answers
29 views

Bash script error [on hold]

I created this bash script based on answers I found here: If [[ $(autorep -J jobname | cut -c108-110 | sed -n '/ST/!'p | sed '/^$/d' | sed -n '/_/!'p) == *ST* ]]; then echo "Status is Started" fi ...
1
vote
2answers
61 views

Cron only occasionally sends e-mail on output and errors

On Debian 8.1, I'm using a Bash feature to detect whether the stackoverflow.com website is reachable: (echo >/dev/tcp/stackoverflow.com/80) &>/dev/null || echo "stackoverflow unreachable" This is ...
1
vote
1answer
27 views

How to suppress exit code of finished background jobs

Is there a way to hide the exit code of the background jobs that have finished? For example, if I run: sleep 5& After the 5s, if I hit return the terminal gives me: [1]+ Done ...
0
votes
1answer
49 views

sed in while read loop doesn't complete commands

I have a test file called testPage with the following text: || '''Title1''' || '''Title2''' || '''Title3''' || || Cell11 || Cell12 || Cell13 || || Cell21 || Cell22 || || Cell31 || Cell32 || || Cell41 ...
0
votes
1answer
24 views

Display Spinner while waiting for some process to finish

How can I show spinner till command line finish it is job? In other words, If I am running a script and I want to show spinner while this script is running and the spinner disappears when the script ...
0
votes
1answer
26 views

DNS Query Script

I am trying to get all the A records for some domains. The best way I have found is to use https://www.whatsmydns.net and the nexcess tool. The issue is that it is very slow to copy paste them and ...
0
votes
0answers
7 views

Zenity, how to manage cryptsetup prompt?

With Zenity, I display a progressBar and install/config many stuff on a Linux Mint (Debian) computer. I had to avoid any prompt. But one step prompts Enter a passphrase:, this is cryptsetup ...
0
votes
0answers
11 views

Zenity. How to run as an application?

I built a script (bash), then I overlaid it with Zenity (to have a progressbar in a GUI for non linuxian users). How can I deliver it as an app, not a .sh ? And never show a square of terminal ?
1
vote
1answer
82 views

'while read line do' cause: “syntax error near unexpected token `done'” in Linux bash script

I have a shell script which is running fine on Solaris platform but not working on Linux platform. The Failing code snippet is as following: [...] while read line do insert_into_table="insert into ...
0
votes
2answers
24 views

Bash script to edit lots of html documents

I have a directory with many HTML documents. Most of them contain the codeblock .org-link { /* org-link */ color: #b58900; font-weight: bold; text-decoration: ...
0
votes
2answers
50 views

Bash script that removes part of a filename in every file under a directory

I have several files under a directory whose names are of the form *.foo.bar. I would like to write a bash script to rename each of these files by removing the .foo part. For example, suppose that ...
0
votes
1answer
20 views

Running repetitive task through Bash script

I'm running a few repetitive tasks and I think will be good to create a small bash script to perform all them in just one command: run the bash script. This are the tasks I need to run: # stop HTTPD, ...
1
vote
1answer
46 views

Script SSH and run command

I must connect to server every day by ssh, and I made a script to display logs. This is my code: #!/bin/bash A=`date +%Y` M=`date +%m` D=`date +%d` gnome-terminal --geometry=82x11 \ --tab --title ...
0
votes
2answers
31 views

How to use if with grep -x

This is my code: if grep -x $idle | grep -x $dead | grep -x $busy ./Event.log then echo " Events are running Successfully" >> ./Event.log else echo "One or more Events are down. Check ...
0
votes
1answer
20 views

Command does not execute properly on remote server

I've been trying to update my backup script such that it saves data on a remote server instead of on a local disk. I have succeeded in converting the entire script but the last part in which I remove ...
1
vote
3answers
114 views

in bash script; a process stdout as filename argument fails when you open it more than one time

Consider this bash script code: #!/bin/bash function bug_part() { cat $1 > sample.first cat $1 > sample.second #second time you open file $1, it contains no data } bug_part <(echo ...
2
votes
1answer
24 views

How to script `make menuconfig`?

I want to automate a linux build but eventually get to a point where I need to run what seems to be a very manual step: make menuconfig. This seems to synchronize configs between the OS and kernel ...
0
votes
0answers
16 views

Character shows up when scrolling through history with arrow keys [closed]

I am thinking my problem is the same (or very similar to) this question but I don't understand the solution if it applies. The selected answer states to use \[...\] to wrap sections with length 0 in ...
0
votes
1answer
36 views

Keys in the keyboard are not functioning in an interactive script!

I am using this code in bash to make my script interactive. I mean by interactive is to let the script ask me questions like what is the path to my data: #!/bin/bash -ef read userInput if [[ -n ...
1
vote
4answers
77 views

Last Working Day of the Month

#!/bin/bash #!/usr/local/bin #!/usr/sbin #!/usr/bin # Script to Check last working Day of the Month echo " Enter Month and Year :" read mon year cal $mon $year| egrep "28|29|30|31"|awk 'BEGIN { ...
0
votes
1answer
15 views

not getting variable's values inside the isql command

Below I am trying to automate the Sybase reporting job but unable to get the variable value as sp_helpdb proc's parameter. Kindly assist me to get out of this. #!/bin/sh . ./SYBASE.sh dblist=`isql ...
0
votes
0answers
29 views

What are the advantage of using tcsh? [duplicate]

I'm a newbie to Linux. I have found tcsh has some advantages over bash. What are the significant advantages using tcsh over bash? For C Programmers is there any specific advantages that bash cannot ...