Questions tagged [bash]

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

Filter by
Sorted by
Tagged with
1 vote
2 answers
3k views

How to use a space in date format section of annotate-output?

I try to use annotate-output (part of devscripts package), to prefix outputs of a script with date and some extra info. First parameter can be a format string passed to date. I want to include a space ...
Vajk Hermecz's user avatar
1 vote
2 answers
643 views

Why doesn't grep work with single quotes?

I have a bash script wrapped in " " so I need to use ' ' for my grep command but it doesn't work. I can't switch the quotes because then the variables are not expanded. #!/bin/bash PWD=`pwd` source "...
Alasdair P's user avatar
1 vote
1 answer
1k views

How can I get file names of opened by a process?

I want to list down all file names opened by init process. I know about /proc/PID/fd directory. But that gives file descriptors only. How can I get file names from list of file descriptors?
techfun's user avatar
  • 427
1 vote
3 answers
860 views

Continue SSH background task/jobs when closing SSH or when Shell is disconnected

I am running an MPI program with SSH secure shell. Due to Wi-Fi disconnection, my la[top looses connection with server and causes failure of running process at server. As per above suggested ...
Vishal's user avatar
  • 13
1 vote
2 answers
3k views

Can't rename volume group in linux that had hyphens/dashes in name

I made a typo when I created an LVM group under Centos 6.4. I'm trying to rename using the syntax vgrename /dev/mapper/oldVG /dev/mapper/newVG. However, both the old and new VGs have hyphens in the ...
kiwisan's user avatar
  • 235
1 vote
1 answer
397 views

Ubuntu How to delete files older than certain file?

There are several files, How to delete files older than certain file X (order by last modified date)?
James King's user avatar
1 vote
1 answer
234 views

What does this name in my shell prompt mean? [duplicate]

When I opened the terminal today on my MacOS laptop I got a last logged on message and on my line where I can type it says JohnBatasiPhone:~ AlbertRenshaw$ I don't know anyone named "John Batas"... ...
Albert Renshaw's user avatar
1 vote
2 answers
665 views

bash script tells me when new computer joins LAN via smbclient

I'm thinking of creating a script that loops until it finds a new IP on the Network created by the router DHCP Server. I am thinking of using NMAP. nmap 192.168.0.1-254 However I am wondering how I ...
Benjamin Jones's user avatar
1 vote
3 answers
14k views

Newline in a for loop

How can i make a newline in a for loop in bash? I've tried echo -e but its not working. When i am opening a log file everything is on a single line. for i in */ ; do sitefolder="$HOME/domains/${i%...
Alexander Kim's user avatar
1 vote
1 answer
341 views

AWK does not work correctly in my system [duplicate]

i cant run this code because of an error awk 'BEGIN {x=0;y=0} { match($13,/([0-9]+)/,a); x = x + a[1]; match($12,/([0-9]+)/,b); y = y + b[1]} END {print "rxPackets:" x " txPackets:" y}' yourfile the ...
Arash's user avatar
  • 726
1 vote
2 answers
1k views

How to log output of a part of a shell script

I'm looking for a concise solution for logging the output of a part of a shell script to a file. Additionally, I still want to be able to follow the life output on screen. From the man pages of "bash"...
Carsten Scholtes's user avatar
1 vote
1 answer
976 views

Disabling "oh-my-zsh" SVN completion

I am using Zsh version: 4.3.11 with the oh-my-zsh framework. When coupled with "oh-my-zsh", Zsh will attempt to autocomplete SVN (and Git for that matter) commands when the TAB key is pressed during ...
krystah's user avatar
  • 1,637
1 vote
3 answers
2k views

Why isn't bash finding my clearly existent Desktop folder?

I am probably doing something stupid/obviously wrong here, but I am trying to pipe in a script with curl and run it in Terminal on OS X. The command I'm using to do this is: sh -s stable < <(...
Hayden Schiff's user avatar
1 vote
2 answers
1k views

Restrict user access to only read from /proc

As a method for setting up some bare-bones systems monitoring, I have a script set up to SSH in, and run some basic shell commands, reading some files in /proc. I would like to create a specific user ...
Brad's user avatar
  • 6,152
1 vote
1 answer
164 views

How to zsh pipe to grep to match remote branches beginning with 'orgin/'

I tried this: git branch -r --merged | grep '^origin/' But I get nothing... When I remove the caret: ✗ git branch -r --merged | grep 'origin/' origin/HEAD -> origin/master origin/...
justingordon's user avatar
  • 1,613
1 vote
1 answer
1k views

How do I write a bash script that makes a phone call on my cell once a matlab process finishes?

If not a call, is sending a text message possible? I have tried setting up an email notification and that worked, but I would prefer if I got a call or a message.
Tanmay's user avatar
  • 111
1 vote
1 answer
1k views

How to bulk rename files by cutting starting at a certain character

I have music file with crappy file name like this: LetMeBeTheOne[Outtakeb-SideTolongMistyDays[2010DigitalRemaster-1.mp3 TheFoolAndMe[DigitalRemaster.mp3 I want to rename the file by cutting starting ...
Widgeteye The Terrible's user avatar
1 vote
1 answer
429 views

Set bash variable so that it can't be unset

I'd like to set an environment variable for all users via /etc/profile that the users can't override or unset. I'm pretty sure this is possible, but I'm having trouble locating the relevant ...
cbmanica's user avatar
  • 175
1 vote
2 answers
502 views

Unhide all .htaccess files on mac

I am trying to unhide all the .htaccess files in my home folder. Below I've pasted what I'm using now, but it isn't working. find ~/ -iname ".htaccess" | xargs chflags nohidden "{}" Anyone knows why ...
jeroenvisser101's user avatar
1 vote
1 answer
407 views

Cannot export or set variable in new shell

I experienced something weird when working on a issue. This command does not seem to work. (Using ` to fill blank line). When using export > /bin/bash -c "echo $FOO; export FOO=BAR; echo $FOO" ` `...
Will's user avatar
  • 401
1 vote
4 answers
579 views

Mac OS X keeps "old" environment variable around

So far I had /Applications/play-1.2.5/ added to my $PATH variable. Now I'm working with 2.2.1, which I installed in /Applications/play-2.2.1 and changed in ~/.bash_profile (which is getting sourced at ...
doque's user avatar
  • 223
1 vote
1 answer
881 views

many doubts related to the ldconfig command?

I am pretty new in Linux and I have some doubt related to this operation that I have found into a bash script on which I am working: ldconfig -v >> /dev/null 2>&1 Reading on the man ...
AndreaNobili's user avatar
  • 7,161
1 vote
1 answer
531 views

Bash preexecute

I'm trying to write bash command wrapper, which will be patch bash current command on the fly. But i'm faced with the problem. As i'm not a good Shell user, i can't write right expression of variable ...
Alex Bender's user avatar
1 vote
1 answer
3k views

Append text with dynamic value in a text file by echo command in bash

I want to append some text in a file through a shell script. I have the following script bash -c 'echo -e "\nserver.id=$1" >> file.properties' saved in the file script.sh This is how I run ...
Pulkit Mittal's user avatar
1 vote
1 answer
487 views

Using the secondary IP in a bash script

I have a Primary IP set for all the system related tasks. Sometimes I have to use my system to carry out different tests and most of the time I have to deal with bash/shell scripts. I want the tests/...
Asad Moeen's user avatar
1 vote
1 answer
371 views

If you're using stdout-stdin already, could you somehow use a higher file descriptor?

Can the following be done without creating a temp.pem? openssl pkcs12 -passin pass:notasecret -in $DATASTORE_PRIVATE_KEY_FILE -nocerts -nodes -out temp.pem cat myfile | openssl sha -sha256 -sign ...
Gert Cuykens's user avatar
1 vote
2 answers
102 views

How to use 2x$$ together linux

the questing is how to use two variables togheter.. ex. $1,$2,$3 are set numb=2 I need to use command: head $$numb that must be the same as: head $2 I tried everything, I need to know what to ...
Denis's user avatar
  • 13
1 vote
1 answer
373 views

Sorting services in Linux

I have a few Linux servers, all running different services. When I run service --status-all, I get a couple screens of output. I thought I'd be smart and pipe it to sort, and see as a group what ...
Canadian Luke's user avatar
1 vote
1 answer
222 views

Vim command line argument not being executed

I've been looking for a command line calendar program for Linux for quite some time now. I realized I should just use vim. I want to be able to easily view a week of todo lists. Currently using this ...
cat pants's user avatar
  • 259
1 vote
1 answer
518 views

SNMPGET/WALK Timeout on Printer

I have an HP LaserJet CP5225n printer that I am using to test SNMP on our network. I'm new to SNMP so I am having trouble figuring out what's going on here. I'm just trying to return the Device name ...
ExceptionLimeCat's user avatar
1 vote
1 answer
2k views

head hangs or doesn't terminate on Linux

I'm using, (uname -a says) Linux ip-x-x-x-x 2.6.21.7-2.fc8xen-ec2-v1.0 #1 SMP Tue Sep 1 10:25:30 EDT 2009 x86_64 GNU/Linux. I've got a script, foo.sh with 100 lines of code and when I run head -...
jcarpio's user avatar
  • 111
1 vote
1 answer
2k views

Ubuntu 10.04 using ssh without entering my password

I know questions like this have been asked before, and I have read them all (that I found). The problem I have is that we have an embedded linux device that we can log into for debug purposes by ...
code_fodder's user avatar
  • 1,551
1 vote
1 answer
264 views

Piping svn diff produces ESC characters (OS X 10.7.5)

Why is it that when I pipe svn diff output to, say less, I get a bunch of ESC characters? $ svn diff | less Index: test/unit/tour_guide_tip_test.rb ===================================================...
André Dion's user avatar
1 vote
1 answer
2k views

Inputting UTF-8 characters into the Bash CLI

I've got a directory listing with files like: drwxr-xr-x 2 nobody nogroup 4096 2011-01-11 21:06 Капкан drwxr-xr-x 3 nobody nogroup 4096 2011-11-17 08:40 СБПЧ When I copy/paste or ...
Dmitry Minkovsky's user avatar
1 vote
1 answer
742 views

SSH bash - am I running a script?

I'm pulling my hair out on this one, but i've been looking around trying to find the answer to why my ssh connection to my vps has "[remote] 0:bash" in green color showing in my bottom terminal vindow....
vpsnewbie's user avatar
1 vote
1 answer
2k views

How to create Bash script when user root logout sending email alert include history

I found the following command: history | tail -20 | mail -s "log `hostname` pada `date`" mailid[at]corporate.com I want to combine it with an automatic logout script: The system should send an email ...
user2684891's user avatar
1 vote
1 answer
6k views

Add milliseconds to existing Unix time

I have a script that returns Unix time in seconds, for example, 1374521719. I'd like to take in this time and place milliseconds to that. Other posts show a simple example of this with the current ...
Tom's user avatar
  • 163
1 vote
1 answer
772 views

Grep to find files that contain ^M When ^m dos2unix and sed or "grep -r $'\r' *" does not work

I use Cygwin and made a txt file using a Perl script. There is a ^M (Windows cariage return) added, and I have no idea how. How do I find ^M when normal ways (^m dos2unix and sed or "grep -r $'\r' *"...
Stenemo's user avatar
  • 314
1 vote
2 answers
4k views

How to return a string from a bash function that contains a filename with spaces?

I'm trying to write a function which returns a string which consists of two parts: option switch filename with spaces. My problem is: How to quote in order to pass the result to another program? #...
Stephan's user avatar
  • 13
1 vote
3 answers
1k views

Line by line not working

Script FILE="/u0146121/bin/list.txt" while read line; do echo $line done < $FILE I am new to bash scripting and trying to figure out this while loop. I want to read line by line from a text ...
mkrouse's user avatar
  • 71
1 vote
1 answer
240 views

Red5 on Debian, output PID

I'm fumbling my way through with this one, as a novice with all things linux so please be patient :) I would like to output the process ID of a program to a file. From my readings this is generally ...
milks's user avatar
  • 113
1 vote
1 answer
572 views

Clean logging with BASH

I have a script that deletes files 7 days or older and then logs them to a folder. It logs and deletes everything correctly but when I open up the log file for viewing, its very sloppy. log=$HOME/...
mkrouse's user avatar
  • 71
1 vote
1 answer
1k views

Select vimenter autocmd's to run based on args

I'm trying to reduce the number of things I need to do when I open VIM. I have the three following scenarios that I'd like to account for: 1. Open vim with a directory specified vim . For this ...
RyanB's user avatar
  • 113
1 vote
1 answer
2k views

Streaming log file contents (piping)

I am trying to understand how piping works and am stuck at this point. A log file is being streamed and its output is being piped to pigz. What I am trying to do is, redirect the pigz content to a ...
Kay's user avatar
  • 13
1 vote
1 answer
4k views

Making a bash script to compile / execute C++

I'm trying to make a simple script that will compile test.cpp but I cannot get it to work. I'm running the script like this: > bash make.sh And getting the following error: : No such file or ...
Trent's user avatar
  • 11
1 vote
2 answers
1k views

Why does xmessage report that user clicked 'x' without displaying message when run from cron?

I have the script below, which seem to work perfectly when run from the commandline with /root/.scripts/peter-laptop-backup-launcher.sh daily (it displays an xmessage asking what I want to do), but ...
Peter White's user avatar
1 vote
1 answer
13k views

sed command working in command line but not in script [closed]

I have a script with the follow code: find . -name "*.html" -print0 | while IFS= read -r -d '' n; do sed -i -r 's/<font color="#bbbbbb">\.<\/font>.*?<input[^µ]*?mabulle\.hide\(\)">//...
To Do's user avatar
  • 2,480
1 vote
1 answer
954 views

Can't run 'rails' inside Tmux session in Terminal

I just tried rails inside a tmux session in iTerm2 and it returns as -bash: /usr/bin/rails: /usr/bin/ruby: bad interpreter: No such file or directory I can run rails outside of tmux . I am using ...
Ye Lin Aung's user avatar
  • 5,650
1 vote
1 answer
12k views

How can I use a bash script to run nmap and capture both IP and hostname?

I want to scan my network; and return an output like this: Network Scan for 192.168.0.* 192.168.0.1 computer1 192.168.0.2 computer2 192.168.0.3 computer5 echo Network Scan nmap -sP -n <network&...
developer__c's user avatar
1 vote
1 answer
2k views

Trap Ctrl+C and repeat the while loop in Bash

I was trying to trap CtrlC or CtrlZ and clear the screen and repeat the loop without exiting – it's working but I need to press Enter to repeat the loop. #!/bin/bash trap 'clear' 2 20 while : do ...
KumarJohn's user avatar
  • 417

1
111 112
113
114 115
235