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

2
votes
0answers
21 views

When would you use $* instead of $@ in Bourne shells? [duplicate]

In Bourne shell and its offshoots like Bash, I believe the only difference between $* and $@ is that $@ expands in double quotes so that each argument ends up as a single word even if it contained ...
1
vote
0answers
24 views

What exactly files whose names' prefix is “AT.postflight.” are needed for?

I am not sure if this question should be asked here, since I am on an OS X, but since I am using bash, and I am asking about the meaning and the purposes of some files. I am trying to understand why ...
-4
votes
2answers
39 views

Web Server Log Analyse

I have a web server log file I have to create a command-line pipeline to display the top ten most visited pages. I then have to embed it in a shell script. I'm completely new to Linux coding so how ...
2
votes
2answers
52 views

Find last time yum update was run

Am building a script to find out when a list of servers was last fully updated with yum update. I can find it by a history |grep "yum update"|head -n 1 however, the problem is that a user could have ...
2
votes
1answer
23 views

What affect does precedence have on background task execution?

The two examples I have are: echo hi & And: (echo hi &) The first will give me the process id as a return result (e.g. "[1] 5627"), where adding precedence operators removes this. What ...
3
votes
1answer
127 views

How do I append an item to an array in a pipeline? [duplicate]

This script should simply add a value to an array through a loop and then show all items of an array. #!/bin/bash data_file="$1" down=() counter=0 cat $data_file | while read line; do \ ...
1
vote
2answers
35 views

(Bash) kill process according to the memory used

i make this script to close a process, but i can't compare a output awk (var1) with a integer. the problem is casting in bash? #!/bin/bash var1= free -m |awk 'NR == 2'| awk '{print $3}' var2= ps ...
4
votes
3answers
74 views

How to use call-by-reference on an argument in a bash function

I am trying to pass a "var name" to a function, have the function transform the value the variable with such "var name" contains and then be able to reference the transformed object by its original ...
0
votes
1answer
14 views

Delete files that are not linked from an html file

Given an html file, something like myfile.html, and a folder with some files in it that are part of the web-page and others that are not linked in the html. How can you delete the files that are not ...
3
votes
2answers
33 views

Function with many arguments but only one switch

I am effectively making a recycling bin via some scripts I made. The first script is pretty much an alternative to the rm command (instead of actually deleting a file, it moves it to a deleted ...
3
votes
1answer
26 views

Notification Listener Behaving Strangely when Backgrounded

I've been struggling to get my IRC-Bouncer/Notification Script working. This is meant to be a script which will automatically login to a remote machine, attach to a screen session (or start one if ...
0
votes
1answer
49 views

Bash will not execute system command in Perl script

Need a Bash file to run a perl script. This is the Perl file. #!/usr/bin/perl -w use strict; system "fastacmd -s $Q -d $NewQuery -o ./gifiles/$Q.$NewQuery.txt"; I have left alot out to avoid ...
0
votes
0answers
28 views

Bash Completion hangs all inputs

When I try to bash complete in terminal my computer stops responding to inputs, although the mouse can still be moved. After a few seconds it picks back up and everything continues normally. I'm ...
4
votes
2answers
68 views

How to shutdown a list of servers, making sure the first one is off before shutting down the next?

I have a list of 17 servers in this format: 172.16.6.45 i-052463fs (test-mv1) 172.16.6.46 i-9e2263rf (test-mv2) I'd like a script that can ssh/login to each and every of these servers and ...
-2
votes
1answer
24 views

Shell script curl limit the try time for page not found

I found following code to check web url. if curl --output /dev/null --silent --head --fail "$url"; then echo "URL exists: $url" else echo "URL does not exist: $url" fi Here if the page not ...
2
votes
1answer
87 views

Why root bash output is colored but `sudo ls` output is not?

In bash (Ubuntu) I get colored outputs either as root (after sudo su) or as a normal user. I checked (after reading this post) the files .bashrc for normal user and superuser and the options related ...
2
votes
2answers
51 views

Alias doesn't seem to read from STDIN

I'm looking for an alias to convert hex from hexdump output into "Python's" hex notation: $ echo "5f 74 34 0c c9 7b 9f f8 7a 7c 46 ff ff 5c 31 26" | sed 's/ */\\x/g' | awk '{print "\\x"$0}' ...
2
votes
1answer
40 views

Is there any plugin for zsh or bash that does heuristic filename completion?

Such as if $ ls program_v1.21.rb program_v2.01.rb program_v2.01_final.rb so when I $ echo progv2fin[TAB] it completes to $ echo program_v2.01_final.rb Sure there must be something, but I ...
-3
votes
0answers
29 views

All linux commands where it is stored in OS (file and path) in RHEL [closed]

Any one tell me all the linux commands where it stored in RHEL and thier folder and file name.
5
votes
3answers
583 views

For loop formatting

I am having trouble formatting nested for loops for long strings of input: I am currently using the below nested for loops to name output files from a separate program that I have omitted: ...
1
vote
1answer
48 views

Prevent path autocompletion from using CDPATH in bash?

On my Mac, bash (version 3.2.53(1)) autocompletes command-line arguments using files only in the current directory. On a Linux machine at work, bash (version 4.1.2(1)) autocompletes command-line ...
0
votes
1answer
31 views

Running script through bashrc causes nesting of tmux panes

I use the following tmux code in a script file tmux-dev.sh and add it to bash using bash /home/rohit/tmux-dev.sh : tmux new-session -d tmux split-window -h tmux split-window -v tmux -2 attach-session ...
3
votes
2answers
129 views

Subtract floating numbers in shell script

I'm trying to do some calculation in shell script with CPU usage. Which return floating point number. But when I subtract this number I'm getting error. See the following code and error. Code ...
3
votes
1answer
29 views

How do you make an alias or function that retains tab completion?

I made an alias to save some keystrokes with working with systemd: $ alias sctl='systemctl' However, this breaks tab completion for the subcommands. Is it possible to alias a command without ...
3
votes
1answer
10 views

Linux init script what does 0<&- &> achieve

Sorry if this is the wrong medium to ask this question. I looking into writing my own init.d scripts to control several services running on my Linux server. I came across an example online which ...
3
votes
1answer
154 views

Shell script error (: not found [No such file or directory]) [duplicate]

I'm using following script on linux server. And which is giving: : not found [No such file or directory] This is the script: # ------------------------------------------------------------------ # ...
1
vote
1answer
44 views

How to use sed to replace keys in a file using a regex?

I would like to modify a file to replace keys, suppose these keys are in the file as: 42NM 52NM 23NO XNNM I would like to replace anything with NM, with the word "Okay". 1 #!bin/bash/ 2 3 if [ ...
0
votes
1answer
30 views

When I press tab for autocomplete in bash I get: “Cannot parse arguments: unknown option -r” [duplicate]

My tab key's autocomplete function is not working. Instead, it spits out this error message: Cannot parse arguments: unknown option -r
2
votes
2answers
37 views

Using reverse SSH tunneling in one step instead of two steps (with -X)

Suppose we have three hosts: miki - my computer behind a NAT vps0 - my VPS mum - computer of my mother, behind a different NAT. The task is to connect from my computer to my mum and keep X11 ...
0
votes
1answer
56 views

I can't change user's passwd on ubuntu

I want change 120 user's password. so I wrote sudo echo 'user:passwd' | chpasswd but I had a message, chpasswd: (user) pam_chauthtok() failed, error: Authentication token manipulation error chpaswd ...
0
votes
1answer
27 views

echo or sed out of a ks-file to generate a mysql_secure script

i will create a KS File (Kickstart for automated OS installation). i install mariadb with the ks file. But it seems a problem to execute the mysql_secure script. My idea is to generate a script in ...
4
votes
4answers
144 views

Null and escape characters

I know that a filename in Linux has no restriction whatsoever excpet for two characters '/' and '\0'. I know that '/' is prohibited because it is a directory separator but is there any other reason ? ...
1
vote
3answers
62 views

How to run an infinite loop in the background

How can I run an infinite loop in the background, while continuing on with the script's execution? Example "script": while true; do something_in_the_background; done ...
0
votes
0answers
26 views

Continuum Anaconda Fedora 22 Linux path

After an update to Windows 10 I encounter problems in my dual boot system so I had to re-install Fedora 22. So, starting with a fresh system I re-installed my work environment. The one installation ...
0
votes
3answers
61 views

find command behaviour inside for loop

I have following part of code inside bash script. for dir in $(find /etc/aaa -type d -maxdepth 1) do #my code done #my code if /etc/aaa directory is not present then i want to exit script with ...
0
votes
0answers
13 views

Continuum Anaconda Fedora 22 path

After an update to Windows 10 caused problems in my dual boot system I had to reinstall Fedora 22. So, starting with a fresh system I reinstalled my work environment. The one installation that has ...
2
votes
3answers
64 views

Grab the last executed command from history as a string and store in variable in bash

I'm trying to grab the last executed command, with options, and store it as a string to be written to a file. I've tried using fc but that can only give me the next to last command (for me anyways) ...
1
vote
3answers
56 views

Process text file - Extract data starting with number

I have a list of contact information I need to process in .txt format seperated by , . We only want to keep SIC codes that start with 65 which is real estate. The command should only check for the ...
10
votes
6answers
455 views

Remove lines from a file depending on lines found in another file

File file1.txt contains lines like: /api/purchase/<hash>/index.html For example: /api/purchase/12ab09f46/index.html File file2.csv contains lines like: <hash>,timestamp,ip_address ...
4
votes
1answer
129 views

Pass BASH array to diff like file contents

I have two bash arrays, say: arr1=( 1 2 3 ) arr2=( 1 2 A ) and I want to compare them using diff. How could I pass the arrays as if they were the contents of a file? I tried a few variations, but ...
0
votes
1answer
44 views

How to use grep with does not contain

In my bash script I'm trying to print a line if a certain string does not exist in a file. if grep -q "$user2" /etc/passwd; then echo "User does exist!!" this is how i wrote it if i wanted the ...
2
votes
2answers
97 views

Find differences in file and sorting file by key

So I have two language files, english and french. They are in this format: key=translation An example in English would be: ui.title=My Title And in French: ui.title=Mon Titre So I need a ...
1
vote
0answers
25 views

Bash completion function for vim 'scp://' Paths

For easily editing remote files with vim, I currently use a few .vimrc and .bashrc additions to my environment. The bash-scripting side of it "misuses" the available standard _scp bash completion ...
1
vote
2answers
51 views

clickable (gui) Bash script?

Was just finishing some script containing a choice menu and was wondering if there's a tool out there that could be called by a script, provides a 1-click-choice-menu and returns the result back to ...
3
votes
2answers
56 views

Convert a value into a “Binary Number” in a shell script

I know of bc: $> var="304" $> echo "obase=2; $var" | bc 100110000 Could it be done in shell (no external call)? This question: Binary to hexadecimal and decimal in a shell script Asks how to ...
1
vote
1answer
19 views

Trying to get the specific information from the array

I need to convert this array: arr=("aa:" "info" "{" "bb:" "name" "value" "50;" "bb:" "surname" "oth_value" "50;" "bb:" "age" "number" "3;" "bb:" "about" "text" "void;" "}") to something like this: ...
3
votes
3answers
64 views

Multiple column matching and adjusting with awk

I have a problem that's giving me a bit of a headache, but it doesn't tend to take much as a relative beginner. I have a file that looks like this ID A1 A2 A3 1 A G A 2 T G A ...
5
votes
1answer
42 views

Using the built-in “time” command in bash rather than the external command

Working with the time command, I came across a situation where I should use the built-in time rather than the external GNU time command /usr/bin/time. So, how can I do this? I saw somewhere that ...
1
vote
2answers
49 views

Escaping a linux command

I'm trying to run a command from a script I wrote that basically replaces a string in file vzctl exec VZID sed -i 's/\/>/address="$IP\/255.255.255.0"\/\>/' "file.xml" The problem is the ...
0
votes
1answer
45 views

Replace command in Bash script from another script

I'm trying to setup a script that will fetch changes from github where a script has a command that's not executable in Mac OS X. What I'm aiming for is to use sed etc to replace the command within ...