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

learn more… | top users | synonyms

0
votes
0answers
9 views

CLI tools/ways for dynamically constructed DOM structure parsing HTML Javascript

I'm planning to make a tool which recognizes HTML using DOM structure in CLI. As many sites produce many DOM elements using JavaScript these days, it's becoming difficult to extract information from ...
1
vote
1answer
181 views

install screen from source code

I tried to install the screen command on RedHat from source code. But when I run the configure, it returned configure: error: !!! no tgetent - no screen So does anyone know how to fix it?
0
votes
0answers
24 views

Connecting to ssh and using screen not working properly

I used once ssh -t <login@server> screen -R to connect to a server and everything worked fine. I used the terminal in the server to execute an script and then detach the screen. I came back ...
0
votes
0answers
10 views

How to run an script using cron in Windows 7 using cygwin?

I have installed all the dependencies in cron. My scripts are working properly, and also I have tested cron which I think works properly as well. However, I would like to set up a task to run a script ...
2
votes
0answers
39 views

How to register shutdown script on Amazon Linux in AWS EC2

I am using Amazon Linux (RH-based distro) in AWS EC2. I followed the structure of /usr/share/doc/initscripts-*/sysvinitfiles to create an init script in /etc/init.d. /etc/init.d/do_something ...
0
votes
0answers
6 views

mc-wrapper does not exit to MC_PWD directory

I recently installed openSUSE 13.1 and set up the mc in typical why by aliasing mc with mc-wrapper.sh to have it exit into the last working directory in mc instance. However this does not seem to be ...
0
votes
2answers
52 views

Is it possible for a root user to watch others' shell session secretly in live?

I see a similar question on stackoverflow: http://stackoverflow.com/questions/1353253/linux-terminal-how-to-capture-or-watch-other-terminal-session Someone recommends conspy. However, it seems that ...
1
vote
1answer
11 views

Trouble creating real NTFS links using Cygwin

I have administrator privileges and would like Cygwin's ln -s to make NTFS links instead of the fake !<symlink> files that only Cygwin understands. I tried the following, based on Cygwin ...
1
vote
3answers
5k views

“command not found” when running a shell script. What did I break?

I'm on OSX Snow Leopard. Here's the full contents of grr.sh: #!/bin/sh echo wow When I try to run it from terminal: $ grr.sh -bash: grr.sh: command not found $ /bin/sh grr.sh wow $ sh grr.sh wow ...
0
votes
1answer
92 views

VLC bash transcoding script destination directory

Well, I have such transcoding script: #!/bin/bash acodec="vorb" arate="256" ext="ogg" vlc="/usr/bin/vlc" fmt="mp3" for a in *$fmt; do $vlc -I dummy -vvv "$a" --sout ...
5
votes
4answers
4k views

Bash says file does not exist, but it does

I'm trying to compile the firmware for my linksys WRVS4400N. ls shows that exist but when it try to run it bash says it does not exist. I can also cat it, and it is an executable, not a shell script. ...
0
votes
0answers
7 views

how come git bash can call java tools (xjc.exe) with unix paths but not cygwin?

From CMD.exe, I can run xjc as follows: xjc "c:/schema.xsd" -p abc -d "temp" From git Bash, I can run xjc as follows: xjc "/c/schema.xsd" -p abc -d "temp" As far as Cygwin goes, I can get it ...
5
votes
2answers
237 views

Checking file names inside a directory with Regular Expressions

I have a list of files inside a directory and I want to make a bash script which uses a regular expression to check if every file name inside it has this syntax: xxxx_xxxx_xx_xx Where x are ...
2
votes
1answer
49 views

Linux Unzip with exclusions from .txt file

I have an unzipping script on Linux. It attempts to unzip with the command: unzip file.zip This is obviously successful. I now wish to exclude some files. The manual tells me of the -x option. I ...
0
votes
1answer
18 views

Bash doesn't source file unless manually started

bash won't source files from an login terminal unless I manually run bash from a terminal, I have bash (and not sh or dash). When I source a file, it returs errors (like "syntax error near unexpected ...
-1
votes
0answers
17 views

Bash - monitoring apache logs

The idea is not ban ips listed in ignoreip.txt but the script continues to ban the ips in ignoreip list. Someone help me fix this? In line 52: for IGNOREIP in cat $IGNOREIPS ; do #!/bin/bash # # ...
85
votes
2answers
57k views

Go back to previous directory in shell

Is there a way to go back to previous directory we were in using bash,tcsh without using pushd/popd ? I'd like to type something like "back" and got returned to the previous directory I was in. Edit: ...
1
vote
1answer
3k views

Howto switch / chage user id witin a bash script to execute commands in the same script?

Is there a way to switch user identity within a script (executed as root as part of an installation process) to execute some commands without calling an external script, then return to root to run ...
0
votes
1answer
25 views

Unable to start bash script with shell_exec

I've been googling and trying to solve this problem with my php script for a few days now and I'm hoping someone here can see the problem I'm missing in getting my php script to kick off my bash ...
0
votes
1answer
17 views

IFS-separated items in loop

It is recommended to use IFS to loop through comma-separated list, e.g. here. But, I see that sentences="Hello World,Questions" IFS=, sentences1=($sentences) # if we comment this line then loop is ...
3
votes
1answer
345 views

How to open a file from bash command line in the already open Emacs instead of a new instance?

How to open a file from bash command line in the already open Emacs instead of a new instance? When I type $ emacs file.txt it opens a new Emacs instance, instead of opening the file in the ...
0
votes
1answer
24 views

Switcher bash script

I want an executable script that changes screen configuration from 1 to 2 or from 2 to 1. I would need a boolean or a variable where the state is saved. It's that possible? Otherwise, how can I check ...
0
votes
1answer
79 views

Way of identifying plaintext file types in bash?

Is there any alternative to the file command that can be used to identify plaintext file types that don't have a magic number? E.g. something I can give a file to that contains JSON and I'll get back ...
21
votes
2answers
864 views

How to create a directory named '-p' under Linux with Bash? [duplicate]

In Bash, how could I create a directory named -p? mkdir -p failed. mkdir "-p" failed. mkdir "\-p" failed. mkdir \-p failed.
5
votes
1answer
7k views

Bash command to cut output after x number of lines

I'm looking for a bash command, which I can use to limit the number of lines of a file or another command output. E.g. ls -thor | limit 10 would limit the output of the ls command to 10 lines (in ...
0
votes
1answer
16 views

Setting include paths in LSF-bsub

I am running a big job on a HPC. But the installed programs for the job are old versions and I have the new versions in my home directory. I can log in to any node, export the path to the new versions ...
0
votes
1answer
32 views

How can I delete the oldest directory in a directory?

I am writing a backup programm, and I need to execute a bash command to delete the oldest directory in a specific directory. I have found this command to print the oldest directory: find -type f ...
0
votes
1answer
344 views

Suppress awk warnings

On a script, I get some warning of the form awk: warning: escape sequence \( treated as plain (. Since I want to use the output of that script to do stuff, I want it to output only results and not ...
0
votes
0answers
17 views

How to capture diff output from find command exec?

I am using Ubuntu (Precise 12.04) I am trying to write some bash script to see if file is changed via awk replace by using diff command. I did a test with the following: #! /bin/bash diff fileA.htm ...
0
votes
1answer
13 views

Backing up recursively is not copying directories

I have the following line in a script to backup and it is not recursively copying all the directories, it gets the files but just lumps them all together. Can anyone tell me what is wrong with it? ...
0
votes
1answer
38 views

'localhost' stoped working as an alias for '127.0.0.1' for SSHing into my VirtualBox VM from OSX. Why, and how to fix?

The question explains the problem. For months I've never had any problems along these lines. Then, yesterday morning, I couldn't get into my VM! Took a long time to troubleshoot but here was the ...
3
votes
4answers
3k views

Irssi settings and Bash's Environment variables

How can I define settings, such as ircname, nick and such things, in .bashrc for Irssi?
0
votes
2answers
289 views

Search for exe file within a condition

I want to search for all .exe files greater than 200 kB or smaller than 120 kB in the current folder and its subfolders. Then I want to move them to another folder called "folder" and execute in this ...
0
votes
0answers
15 views

cURL form parameters: read contents from file and set type

I'm trying to perform a PUT as follows curl -X PUT \ -H "Content-Type:multipart/form-data" \ -F "JSON_Param=<file.txt;type:application/json" \ -L "$MY_URL" where file.txt contains ...
1
vote
1answer
23 views

Bash script - Trying get abuse email using whois command

How can I get only e-mail address from output? $ whois $IP | grep @ | head -1 notify: albert@xxx.sig.xxx.tw
0
votes
2answers
25 views

using 'case $1 in' to read command options- multiple flags after dash, and handling unusual flags?

I am making a bash script which uses both long options and short flags. Since I want long options, I can't use getopts. I tried using the following code: while test -n "$1"; do case "$1" in ...
0
votes
0answers
22 views

Batch replace non-ASCII characters in filenames

I'm looking for a shell script that will recursively replace non-ASCI characters with underscore or just remove them. The issue is that a drive with files, created on Linux, has to be used on ...
0
votes
2answers
71 views

How to rotate enumerated filenames similar to logrotate?

I have a couple of files, let's say map-0.jpg (newest), map-1.jpg, map-2.jpg, ..., map-9.jpg (oldest). Now my cronjob downloads a new picture from the internet and should save it as map-0.jpg. All ...
-1
votes
0answers
21 views

Why Ii obtain this error when I try to compile and install a software on Ubuntu 14.04?

I am not yet a Linux guy and I am going crazy trying to install a software compiling it on Ubuntu 14.04. This are the only provided instruction to install it: Debian First, make sure that ...
0
votes
1answer
26 views

Bash script analyse apache log

I need help with this script This script analyses apache_access.log through a filter.txt, if exist the term in filter the script will do something. My problem i think is in the first command "for", I ...
2
votes
8answers
9k views

How to find the index of a word in a string in bash?

In bash script, I have a string which contains several words separated by one or more than one spaces. ie: Name Age Sex ID Address If I want to find any of the word, for instance I want ...
1
vote
2answers
35 views

Execute a previous command in a shell and get the command directly after

Once, a colleague of mine shown me a very useful method (shortcut?) on a shell (bash? csh?) to, after executing a previous command, automatically show the command after in history. For example, ...
6
votes
5answers
509 views

How to write a script that accepts input from a file or from stdin?

How can one write a script that accept input from either a filename argument or from stdin? for instance, you could use less this way. one can execute less filename and equivalently cat filename | ...
7
votes
5answers
16k views

How do I rename files with spaces using the Linux shell?

I named a number of files with spaces in them, and I want to replace the space with "_". However, every time I write a command in the shell with the file name (eg "Spring 2011"), the shell doesn't ...
1
vote
0answers
10 views

How can I redirect OS X dtruss output when running with sudo?

I'm running dtruss on Mac OS X 10.9. Simple example is: sudo -c ls But I'd like to capture the dtruss output into a file. I saw something that suggests that I can do something like: sudo bash -c ...
48
votes
7answers
44k views

How do I add text to the beginning of a file in Bash?

Hi I want to prepend text to a file. For example I want to add tasks to the beginning of a todo.txt file. I am aware of echo 'task goes here' >> todo.txt but that adds the line to the end of ...
0
votes
0answers
7 views

cygwin's chmod behaves as working, but it does not work

My Cygwin installation is behaving strangely: chmod does not work. [09:45 Administrator@DellIns14 ~] > ls -ls /usr/bin/chmod 64K -rwxr-xr-x 1 Administrator None 38K Feb 6 2012 /usr/bin/chmod ...
-1
votes
1answer
27 views

Using /usr/bin/env to change directory [on hold]

I want to automatically execute commands with the prefix /usr/bin/env $/usr/bin/env composer install (this runs OK) $/usr/bin/env cd public (failed ---> /usr/bin/env: cd: No such file or ...
0
votes
2answers
15 views

Piping Several commands in a BASH shell

I am trying to recursively loop through a directory which contains numerous other directories and files and then find all the .rb files and copy them to another directory. This is what I have so far ...
0
votes
1answer
25 views

Removing files and directories that already exist in other directories

I need a help writing a script. So basically I have directories named by current date, like 01-06-2014 02-06-2014 and so on each of these directories has files and subdirectories inside. But sometimes ...