Bash is a free shell for Unix-like operating systems, from the GNU Project

learn more… | top users | synonyms

1
vote
3answers
23 views

Parsing the output of “uptime” with bash

I would like to save the output of the uptime command into a csv file in a Bash script. Since the uptime command has different output formats based on the time since the last reboot I came up with a ...
0
votes
0answers
10 views

shell script over SSH ends unexpectedly after running 'ant build'

I wrote a shell script that runs on remote host to build source code with 'ant build' command, and then distribute the built binary to other servers. However, right after Ant build is over ...
1
vote
2answers
33 views

In bash, how I define a “command scope” variable?

I'm reading this book on the bash architecture and one of the bash maintainers says: There are different variable scopes for shell function calls and temporary scopes for variables set by ...
0
votes
1answer
14 views

Open gnome terminals programmatically with a script that requires a doublequote

I am trying to use a wrapper.sh script spawn separate terminals for a script that takes params in doublequotes, like so: #!/bin/bash gnome-terminal -e "./script.py -d "somevalueforscriptpy" $1" ...
0
votes
1answer
19 views

How to collect specific data?

I have a text file like this abcdxxxxx abcdxxxxx 1234567 - abcxxxx from that file I want to separate only the strings with abcd as header part. Help me please. Thank you.
0
votes
2answers
25 views

Is there any reason this cronjob would fail in cron, but not on the command line?

I have written a little one liner that will email me when a list of files changes - I used sha512 to generate a list of hashes and then periodically check that those hashes still match. */5 * * ...
0
votes
1answer
17 views

Weird output in my mac iTerm bash shell. How do I make it clean?

Setting up my bash and made some mistake. Here is my bash shell: android-c26f663baae722eb:~ okyretina$ I have used a clean .bash_profile and sourced it and the shell still have that weird ...
1
vote
0answers
21 views

How to give each virtual terminal in GNU Screen it's own background color?

I have a dream: I want each virtual terminal within GNU Screen to have it's own unique background color. I think I can fake it in an .bashrc script that emits xterm control codes to set background ...
1
vote
4answers
86 views

Avoiding users to corrupt and use a script

Is it possible to deny the right to copy files? I have a script which should be executable by others. They are also allowed to read the file (though it would not be a problem to forbid reading). But ...
0
votes
0answers
16 views

Raspberry in kiosk mode - How to secure bash or change matchbox for switching tty

I want change my raspberry to a kiosk pc. It works well and is complete, but with some mechanics I've some trouble. The actual problem is, that the autologin mechanism is defeating the purpose of ...
0
votes
0answers
14 views

Automaticly run xinit from rc.local as different user

I'm working on some tuning of my raspberry pi b+. So I decided that midori should start automaticly after autologin. With startx it works without problems, but X is still to ressource hungry. So I'll ...
0
votes
1answer
22 views

How to print index in a 'for-loop' being executed in remote host through SSH?

I want to ssh into a remote host, and then execute a for loop that goes through sequence of numbers to control number of different nodes. ssh user@host /bin/bash << EOF for i in {1..10} do echo ...
2
votes
2answers
47 views

How do I delete all lines but the last one using unix ed editor from a bash script

I have the following bash file called "file" (the real one does something useful): ed db/seeds.rb <<EOF 1,$-1d a 123 456 . w q EOF When I run "bash file" it doesn't delete any lines. If I use ...
2
votes
3answers
49 views

Why is this sudo command try to run in /root?

I try to run a sudo command via SSH like this: ssh domain.com sudo -u user bash -c "cd /home/user/ && ls" (which is obiously just an example). I get back: /home/user/: line 0: cd: /root: ...
0
votes
1answer
24 views

Is \d equal to [0-9] in sed?

7 00:00:30,008 --> 00:00:30,066 by line 8 00:00:31,038 --> 00:00:34,050 or later in the nineteen seventies it was usually a 9 00:00:34,005 --> 00:00:38,634^M video consul but the council was ...
0
votes
1answer
42 views

Enter response once prompt returns?

It's neither a secure idea nor one I'd recommend elsewhere, but I have a situation when occasionally it takes a while for my Ansible ad-hoc command to respond. I'd love to pipe or args or whatever is ...
0
votes
1answer
31 views

bash doesn't show current working directory on screen

When using iTerm2 on my OS X, the bash prompt shows my current working directory normally: mbp:tp0 renato$ But when I use screen, the bash prompt changes to: bash-3.2$ How I make the bash prompt ...
0
votes
1answer
13 views

Why doesn't the binary package get reinstalled by apt-get or building from source?

I'm trying to install Asterisk on my Debian wheezy server. For this I first did the simple sudo apt-get install asterisk This worked flawlessly. Afterwards asterisk was running and I could enter ...
0
votes
1answer
13 views

ssh to production to www-data user

I build an automation for deploys, that we connect to our productions servers and then perform a git pull in the project. The project is owned by "www-data" so I need to to --> ssh ...
2
votes
2answers
22 views

How to check if a directory is under svn version control?

From a linux bash script, how can I verify if some directory is under svn version control? I am using svn version 1.7.9. When I try the following pushd ${WD}; svn info; popd and check the error ...
0
votes
1answer
23 views

Alias to connect to AWS instance via SSH not working

I made an alias to make it easier to connect to my AWS EC2 instance. Although there is an error. Here is the code in ~/.bash_profile: alias aws_connect=‘ssh -i /path/to/keyfile.pem ...
0
votes
1answer
21 views

How to get when run `top` command ports listed?

How to get when run top command ports listed ? I get info about process but I need port to see ( process dies very quickly , 0 seconds, and I cannot grep after ps aux ). Is possible to top command ...
0
votes
2answers
34 views

Files listed by bash but unaccessible

What would cause the following behavior on an Ubuntu 12.04 system? I've SSHed into a machine as the "ubuntu" user. Running ls -lah /data/* shows dozens of non-empty files (e.g. file1.txt, file2.txt, ...
-1
votes
1answer
42 views

How to use HTML markup tags inside Bash script

I have crontab and a simple bash script that sends me emails every often containing PHP, NGINX, MYSQL errors from their log files. This is a simplified example. #/home/user/status.sh ...
1
vote
2answers
22 views

two processes are listed for one shellscript?

I have a shell script which does somewhat simple. #!/bin/sh do something boring... When I execute the shell script like this, $ nohup sh mysh.sh > /null/dev/ 2>&1 & I see there are ...
0
votes
1answer
14 views

How to clean up output from `watch git gc`?

git gc updates the output as it runs, perhaps using backspaces, control characters, and/or curses. (I'm not an expert on this.) How can I modify my watch -n 60 git gc bash command so that the output ...
0
votes
1answer
29 views

How to pass output of command to sed

My sed command in #Update key in config file. does not get the contents of the variable $GETKEY Someone help me? # Get key from output of the website. GETKEY=`wget https://www.badips.com/get/key ...
0
votes
0answers
8 views

busybox cp 'are the same file' when copying directories

I'm porting a bash script that worked on OS X to Windows+BusyBox. The first command is to create a new directory mkdir ../new_directory Then to copy all files from the current directory to a new ...
0
votes
0answers
21 views

Check for available command

When I execute the bash script with root user I receive the output it say iptables not exist. Why this happens only with root? for CMDAPP in "hash" "curl" "iptables" do if ! hash "$CMDAPP" ...
0
votes
0answers
15 views

Desktop Gone in Centos 6

I had a third party library created a ~ folder (a bug there), and I tried to delete it by "rm -rf ~". And apparently, it is a mistake -- my session got rebooted and then when I went back in, all the ...
0
votes
1answer
10 views

Drush commands not found when called from a bash script

Relevant system background: I'm using MAMP on OSX. Output of which php is /Applications/MAMP/bin/php/php5.3.14/bin/php Output of which drush is /Applications/MAMP/bin/php/php5.3.14/bin/drush Output ...
0
votes
5answers
29 views

History in bashrc on login vs manual sourcing - clearing and loading

I use a bunch of different aix machines at work and need to share users with co-workers. To make my life easier but not bother others with my customizations, I have created a .bashrc file that I copy ...
0
votes
1answer
26 views

Memory usage of a process in a shell script

I want to find out the memory usage of a process in a shell script.I tried to use this piece of code : while[process] do if [ -e /proc/$pidno/statm ]; then m=`awk '{OFS="\t";print ...
0
votes
1answer
37 views

How to verifying variables correctly in Bash?

I have the following code: #!/bin/bash FILES=known/* arp-scan -l > temp_scan.log cat temp_scan.log | while read line do for f in $FILES do echo ...
6
votes
2answers
130 views

Is there any in-built Linux command to display the contents of a directory in real-time?

Is there any in-built Linux command to display the contents of a directory in real-time?Similar to the "tail -f file_name" command which displays the contents of a file in real-time.
2
votes
3answers
75 views

What is the differences of these concepts(Shell, Terminal, Console and Command-line) in Linux?

As a rookie, these three concepts: Shell, Terminal, Console and Command-line have been puzzling me a lot recently. Especially Console and Terminal?
-2
votes
0answers
23 views

What kinds of connection between Enter key on the keyboard and Line Feed or Carriage Return in Linux shell like Bash?

What kinds of connection between Enter key on the keyboard and Line Feed or Carriage Return in Linux shell like Bash? When the Enter key was hit, what does shell receive? Line Feed, Carriage Return or ...
0
votes
0answers
16 views

smbclient fails silently to copy file in bash script

I have the following script: #!/bin/sh BACKUP=/respaldoBD NOW=$(date +"%d_%m_%Y") SMBCLIENT="$(which smbclient)" DBS="zabbix" for db in $DBS do FILE="mysql_$db.$NOW.gz" echo $FILE PARM="prompt; ...
0
votes
2answers
43 views

Linux zip and exclude directory in Bash script

I am trying to write a bash/shell script to zip up a specific folder and ignore certain sub-dirs in that folder. This is the folder I am trying to zip "sync_test5": My bash script generates an ...
0
votes
2answers
28 views

How to execute a command within a bash script?

I am writing a script that will continuously broadcast some data to port 30000, so a python udp listener can get the data and insert it into a table, from which I can draw that information and display ...
0
votes
1answer
51 views

searching large number of possible file names in large directory tree

I need to search a large directory tree for a large number of possible file names, i.e. I have an input file with a long list of strings that I need to find in the tree (or as below: print all those ...
0
votes
0answers
19 views

Need to source bash_profile each time

I have get a server space that runs linux. A user is created for me. I have a bash_profile in my home directory and I set environment variables for JAVA_HOME and JAVA. When I access server through ...
0
votes
1answer
15 views

cd into first/second/third directory returned by ls -d */

Say I am in a directory code: /code /very-long-and-descriptive-name If I want to cd into that directory (or a directory if it comes first in alphabetical order), I can just cd *. Now say I add ...
-1
votes
0answers
48 views

Show all output in same line [on hold]

I think is the for command that create a new line in output. How can show the count of the ip address in same line? Desired E.g: 6 999.999.999.999 for IP in `grep -h "$TERM" ...
0
votes
2answers
37 views

Permission denied for root and “cd /” issue

I am having an issue, first of all I can not cd freely from the terminal, for example: [eldritch@localhost ~]$ ls Desktop Documents Downloads Music Pictures Public Templates Videos ...
0
votes
1answer
55 views

Is it possible to run a dialog/whiptail script in one TTY from another?

The origin of this question, for me, is being able to run a whiptail command in a %pre script from a kickstart file when installing a custom distribution based on Centos. However, the behaviour ...
0
votes
1answer
19 views

“.” command doesn't work in fish

I'm using fish and I'm trying to activate a virtual env, so I tried "source" command which apparently is not available in fish. And I ended up with this link which says: ". (a single period) is an ...
1
vote
0answers
12 views

Auto find file parameter in bash

I've been trying to construct a method for bash to auto complete a file argument. so when you type vi not[tab][tab] it auto completes to notes.md if it is within the history or path or gives a list of ...
1
vote
4answers
30 views

How do I test whether a variable has multiple non-blank lines in bash?

Say I have two variables in bash: MULTILINE="I have more than one line" SINGLE_LINE="I only have one line " I want to detect when a variable actually contains more than one line of text, ...
2
votes
3answers
40 views

In a Linux shell, why does backslash-newline not introduce whitespace?

When using the Linux shell, I come across the following situation: $ A=B\ > C $ echo $A BC In my mind, when the newline encountering escape character, it can not be a CR character but it still ...