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

learn more… | top users | synonyms

1
vote
2answers
1k views

Remove a file extension case-insentively in Bash

I want to remove the suffix of a file by using basename in a Bash script. The command removes the suffix only in a case-sensitive way though. How can I remove a extension case-insensitively?
0
votes
1answer
322 views

After running less command in -bash, instead of a prompt, I get “(END) ”. What's happening, and how do I get the prompt again?

I run the bash command "less" on a .txt. After printing out the lines in the file, the name of the file and "(END) " is printed. But I do not get a command prompt again. Other than closing the ...
0
votes
1answer
384 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 ...
5
votes
2answers
4k views

Permanently disable screensaver Fedora 19

I am creating a bash script that will 'setup' a client machine running Fedora 19 (GNOME). I need to be able to permanently disable the screensaver with no user input. I found some (granted, old) ...
5
votes
3answers
6k views

How to create symbolic links to all files (class of files) in a directory?

I would like to create symbolic links (ln -s) to all files (or a class of files, e.g. ending with .bar) in a certain directory. Say I'm in the cwd and type ls ../source/*.bar gives me foo.bar ...
1
vote
1answer
50 views

When I type on SSH, the letters show up slowly

Right now I'm using wi-fi at a cafe. When I type commands on my local machine in bash, it shows up at the rate I'm typing. However, when I type commands on an ssh account, it shows up very slowly... ...
7
votes
5answers
2k views

How can I make a Bash Script take an input before the script is invoked?

Basically, you call my Bash Script by typing mybashscript in console. Then this starts: Welcome to mybashcript! Choose an option (login|logout|view|erase|quit|): The user then types whichever input ...
0
votes
2answers
90 views

SCP long directories

Im wondering what the quickest way for this is On my local computer I have a file in /some/long/path/name When i have SSH'ed into another machine I decide I want the local file to go in ...
2
votes
1answer
241 views

Bash Script does nothing

I am trying to create a shell script i can run from anywhere in the terminal, the script simply echoes a message #!/bin/bash echo "Excellent work Snake!" I changed the scripts permissions with ...
2
votes
1answer
231 views

“du -h” with more decimal places

I'm working on a little util tool written in bash that gives me some information about a game server on Linux. For that reason I need a possibility to display the size of the file contents. I'm doing ...
0
votes
2answers
971 views

Uninstalling Homebrew messed up git

I uninstalled Homebrew using http://superuser.com/a/203740. After running the above commands, I can't find .bashrc and .bash_profle. All files are gone from Documents , Desktop and Downloads :'( ...
0
votes
0answers
36 views

Uninstalling Homebrew messed up git [duplicate]

I uninstalled Homebrew using http://superuser.com/a/203740. After running the above commands, I can't find .bashrc and .bash_profle. When I do git status on /Users/ava it shows: # On branch master ...
-1
votes
1answer
84 views

Script to email admin in the event of an attack

I'm using a Script that would automatically do a dump of the attack as soon as it exceeds a threshold. The scripts looks like the following: interface=eth0 dumpdir=/tmp/ while /bin/true; do ...
3
votes
1answer
2k views

Batch download of URLs from command line multithreaded

I have 100,000 URLs of small files to download. Would like to use 10 threads and pipelining is a must. I concatenate the result to one file. Current approach is: cat URLS | xargs -P5 -- curl ...
1
vote
1answer
238 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 ...
4
votes
1answer
402 views

readline / bash: How to map Escape key and Arrow keys?

From another piece of command-line driven software, I'm used to the following behavior: Arrow up / down go through the command history, matching lines that match the characters typed so far on the ...
0
votes
1answer
692 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 ...
0
votes
1answer
90 views

Is there a simple way to remotely administer devices shipped to clients?

I plan on shipping small devices (like a MinnowBoard or CuBox) to some people. Is there some sort of software package that can "phone home" so that i have a way to administer it? My current ideas are ...
0
votes
1answer
522 views

Type an EOF without a line break

I have a little command that I use to copy/paste files around that involves pasting the base64-encoded tar archive into stdin, but the base64 utility keeps giving me and error message about my input ...
1
vote
1answer
438 views

Get cpu temps from terminal using Cygwin?

I am using Cygwin 64 on Windows 8 and would like to use the bash interface to get cpu temperatures (4 cores, as well as gpu temps). Is this possible? I am using the temperature monitor application and ...
0
votes
2answers
217 views

Writing a single line command that interprets conditional output from pdbedit

I would like to run a command on a single line that will tell me if the flag is set for a user's password to be changed on next login. This command will interpret the output and return a true/false. ...
0
votes
3answers
1k views

How to schedule/unschedule cron job from shell

I have a ubuntu server where I put my application core. It's a jar that needs to be always listening for requests. I made a script to run it with the correct parameters. The scenario is similar to ...
2
votes
1answer
416 views

Sort lexicographically in bash

I want data to be sorted in the way Python sorts it, comparing ASCII values. But sort command seems too clever for that. Take a look. Since '.' < '9': $ sort . 9 ^D . 9 $ sort 1. 19 ^D 1. 19 ...
1
vote
2answers
422 views

Change names in a column in bash

I have a tab-separated file in Linux that looks like this ~$ head list.tab "x" "1" "FUHGF.jnf.m22-1" "2" "HDFHFEY.gfs.d2-1" "3" "KJFGJF.fr.md2-1" "4" "SDFSDIB.gfd.rtl2-1" "5" "FGJFGOB.hgd.k2-5" "6" ...
0
votes
1answer
158 views

Is it feasible to have a machine work both as server and client on SSH?

I have OS X and within it installed Ubuntu 13.04 via Parallels 8, and I also have iMac, within it I installed Ubuntu 12.04 (not Virtual Environment). So, now I have three OS - OS X, Ubuntu 13.04, and ...
3
votes
2answers
1k views

`vi` command doesn't open newly installed Vim 7.4 on OS X

I just installed Vim 7.4 on my MacBook using Homebrew. When I enter vim on the command line, it successfully enters Vim 7.4, but when I use vi I still get the old 7.3. To install Vim 7.4 I used this ...
0
votes
2answers
509 views

Rename and reverse the numbering of a list of files

In Linux, preferably using bash, what would be the best way to achieve the goal below? Say I have a series of numbered files 001.png, 002.png, 003.png What is the best way to move/rename them to ...
2
votes
5answers
1k views

merge groups of lines with sed

I would like to merge each group of lines from file : <tr> <td >441</td> <td >S</td> <td >0,74</td> </tr> ...
0
votes
1answer
62 views

What would an update mechanism look like in bash

I have to update a script compilation from time to time but I haven't any idea how to start a version check script in bash. I've got a version file with 3 vars: version=0, subversion=0 and ...
0
votes
2answers
6k views

Linux cp Permission denied on ntfs file system

Could someone kindly explain why I get this Permission Denied error? I personally am user g and as ls shows I have read and write permission for both source and destination. My system is slackware ...
1
vote
1answer
248 views

xargs in shell script

I want to group jpeg images by odd number and even number. So I did like following: $ mkdir odd $ mkdir even $ find . -regextype posix-egrep -regex ".*[13579].jpg$" -print0 | xargs -i -0 mv {} odd/ $ ...
2
votes
1answer
658 views

Why do my $PATH and /etc/paths Differ?

Typing export $PATH in Mountain Lion's Terminal returns ...
1
vote
1answer
295 views

Gitolite3 SSH info failing

I have installed gitolite3 from the EPEL repository to Centos6.4. There were a number of things that I didn't like, so I set about to change them. First, I created an additional user and group called ...
2
votes
1answer
99 views

Invoke a script for every command typed at shell prompt?

On bash, is there any simple way to run a command every time another command is entered in your shell? I know about 'trap ... DEBUG', but unfortunately it does not run the specified code for every ...
3
votes
1answer
165 views

Quote or bracket completion in bash, without pressing TAB

Is there any way to have bash autocomplete matching symbols like '"[{( with their right handed counterparts? I would like to do this without having to press tab. For example typing the string echo " ...
1
vote
2answers
4k views

How to auto commit to my git repository using cron?

I look into a lot of answers about this subject, but something is wrong here, let me explain. I create this script, to make my cron cleaner :) #!/bin/bash cd ...
1
vote
1answer
50 views

Use emacs to edit in-memory text

Is it possible to somehow edit in-memory text in emacs? (I.e. without going via the file system.) I'm writing a script in which I need to edit the output of a command and then process the edited text ...
1
vote
1answer
137 views

Delete all lines of text in the HTML file in addition to the first?

I have to rewrite a lot of HTML files, example: *--file1.html--* <p>text1</p><br> **<p>text2</p><br> ...<br> <p>text(n)</p>** *--file2.html--* ...
1
vote
1answer
122 views

Making bash command history act like Windows command shell

In bash, up arrow recalls the previous command. Tap it twenty times, I get the command from twenty places back in history which I ran five minutes ago. Suppose I run that command right now. Now when ...
0
votes
3answers
2k views

Better way to replace timestamp by date when reading a squid log

Tonight i was trying to look at my proxie's lines, and I came up with this, which seems all but KISS. How would you do it simply ? awk '{ trunc=sprintf("%.0f", $1) ;$1="" ; system("echo -n `date +%R ...
0
votes
1answer
747 views

Recover lost .bashrc

So I did something exceedingly stupid and now my .bashrc file is gone. Is there any way for me to recover it? I still have a terminal window open that uses the old bashrc file. If there's no way for ...
1
vote
0answers
36 views

How to make tab completion work within parentheses

On my Ubuntu machine, I can do this emacs $(which first-part-of-executable<tab> and bash will tab-complete the full executable name. I enabled this myself by adding complete -c which to ...
0
votes
1answer
364 views

howto change screen hardstatus dynamically with format, from shell?

howto change screen hardstatus dynamically with format, from shell ? I successfully configured screen using 256 colors and tabs and so on, here is my .screenrc : http://pastebin.com/g8XbMWBH I use ...
0
votes
2answers
1k views

set global variable AND use stdout from bash function

Here's the code: #! /bin/bash function foo() { G1=123 echo "ReturnVal" } RV="$(foo)" echo "RV=$RV, G1=$G1" # RV=ReturnVal, G1= foo >/dev/null echo "G1=$G1" # G1=123 I want to execute ...
5
votes
1answer
7k views

How can I avoid the “grep: Argument list too long” error?

I'm using Mac 10.7.5 and on a bash shell. I'm trying to find instances of a string in a group of files but keep getting this error Daves-MacBook-Pro:folder davea$ find . -name "*" | xargs grep ...
0
votes
1answer
2k views

Save result of a grep -c into a shell variable

How can I store the result of grep -c as an integer in a shell variable? This: check=sudo virsh list |egrep -c '\b[0-9]{2}\b' only gives me the number of matches and prints it on screen whereas ...
1
vote
1answer
79 views

How to “share” a screen session?

Is it possible to start a screen session and have some other process attach to it without having the original process detaching it? Like two terminal windows seeing the same, for example.
0
votes
1answer
64 views

Sed/Awk line double

I have a list like this. Bob Jim Steve Is there a way in bash to turn that into a list like this? <a href="http://example.com/Bob"> Bob <a href="http://example.com/Jim"> Jim <a ...
1
vote
1answer
198 views

Better way to extract a substring in bash

I have a list of mp3 files named like so: $artist/$album ($year)/$tracknum $title.mp3 Many of these tracks have incorrect or missing tags, which I am correcting through the use of id3v2 and regex ...
4
votes
2answers
200 views

Using for loops on command line - variable not working?

Simple for loop on the command line: cobrakai$for((i=1;i<=10;i+=1)); do echo "Welcome $i times"; doneWelcome 1 times Welcome 2 times Welcome 3 times Welcome 4 times Welcome 5 times Welcome 6 times ...