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

learn more… | top users | synonyms

0
votes
3answers
178 views

Replace string in string but not when its somewhere between double square bracket

I have a long string from mysql field containing the data of a mediawiki page. I have to replace a string in that mediawiki page but not when the string is in mediawiki link. The mediawiki link is ...
0
votes
1answer
70 views

Expand bash variables inputted from the read command

I have a tab delimited file like this: table_a "where id IN ($IDS)" table_b "where fk_id IN ($IDS)" table_c "where fk_id IN ($SOME_OTHER_IDS)" And I'm trying to write a script like: ...
1
vote
1answer
46 views

BASH, writing array to nl_012_\n delim string

Working in BASH GNU bash, version 4.2.25(1)-release (x86_64-pc-linux-gnu) under Ubuntu 12.04LTS I'm having an issue with writing the contents of an array into a string delimited by new lines. I ...
1
vote
2answers
224 views

Tail and grep recursively?

Trying to tail though a list of domains to search for a hacker code. All the files that I'm looking for are the same so I was trying something like this: grep -rnl * -e "Ai9LbaFz7lC13SwzDxAYT72vwA" ...
2
votes
3answers
8k views

How to login as root from Bash and do stuff

This is my simple bash: cat test.sh #!/bin/bash echo "hello" su - root -c /path/to/script.sh <<EOF password EOF whoami echo "good bye" But I get this error: ...
0
votes
2answers
111 views

What does “vi-move” keymap in Bash's vi mode actually do?

The keymap section in the Bash Reference Manual says that one of the acceptable options is "vi-move". There doesn't seem to be any description for what this corresponds to. I'm well acquainted with ...
0
votes
1answer
257 views

bash: Running a program from the console without holding it up or line noise

I would like to run programs (for example, opening PDFs in Evince) from my bash shell. However, when I do this the simplest way (evince filename.pdf), the shell doesn't let me input anything until I ...
0
votes
3answers
34 views

How to get out of being suspended by bash console?

In unix-like system terminal, I sometimes used some commands incorrectly and make bash don't know what to do, but just pending on a newline. e.g. grep 'word' -R Then how can I make up to the ...
1
vote
1answer
171 views

Bash single quotes in find command

I'm having some troubles getting a shell script to work. I'm trying to dynamically generate the find command based on user input and I'm running into the problem that my variables in the find command ...
3
votes
2answers
926 views

Is the cp command case sensitive on OS X Mavericks (10.9)?

Is this a bug in OS X or I have something misconfigured? $ touch aaa $ ls -l total 0 -rw-r--r-- 1 jchen 1366545133 0 Feb 16 16:08 aaa $ cp aaa AAA cp: AAA and aaa are identical (not copied). $ ln ...
0
votes
1answer
504 views

Archlinux - Autostart `screen` after boot

I'm building some small internet radio player using Archlinux. All I need right now is to autostart (without login!) script or just command: su -c 'screen "vlc (a lot of parameters)"' vlc_user By ...
1
vote
2answers
1k views

How to compare the contents of two directory using bash?

I have 2 directories that should contain the same files and the same directory structure. I think that in one of these directories missing something. Using the bash shell are there a way to compare ...
1
vote
2answers
56 views

Find two newest change files and compare them

I have a script that wgets a .txt file and datifies the names. I'd like to diff the changes between the newest & next-to-newest file. This is how I am able to select them: ls -t -l | awk ...
1
vote
0answers
649 views

find command with exec sh doesn't work in shell script but in commandline (raspberrypi)

I want to find "old" folders in /volume1/photo/ipcam which are named like "????-??-??" and move corresponding folders within dropbox (with the same directory structure /ipcam/...) to the subfolder ...
2
votes
2answers
190 views

env -i zsh | How is this magic possible?

I'm currently working, for school, on a home-made shell, therefore I'm kind of curious nowadays about how shell vars are set. Yes, this can be really exciting ! Anyway, we obviously have to deal with ...
0
votes
2answers
399 views

Pipe core dumps from script

I am making a testing script to compile (via make) and run a bunch of tests. I have a series of cat, grep and sed commands that organizes the results of all the tests nicely, however core-dumps are ...
4
votes
1answer
433 views

getting “command not found” when using source command on Fedora

I am using Fedora. When I issue: -bash-3.2$ source na-profile.conf I get: : command not found : command not found : command not found The na-profile.conf file looks like: KEYTAB=server02 export ...
0
votes
1answer
55 views

Tell me, when script has finished

Some years ago I had a small script[1] called beep-forever which ringed the terminal bell for ever. Use case: I want to know if a script has finished: do-foo-which-lasts-ten-to-thirty-minutes.sh; ...
0
votes
3answers
193 views

How do I exclude match and change only specific character with sed

I am trying to use sed to replace '0' with the word 'correct' (I am using echo $? to validate my script and I want to replace the output of echo). The problem is that I have more text in the output ...
0
votes
1answer
306 views

Running qtfaststart in a folder containing multiple .mp4's

I have a library of videos, all of which need to be adjusted for web-streaming by putting the moov atom ahead of the rest of the video with qtfaststart. This allows playback to begin before the client ...
1
vote
1answer
266 views

Linux Bash Shell - File globbing specific range?

I have a bunch of files in a folder: spreadsheet700.xls spreadsheet800.xls spreadsheet850.xls spreadsheet1005.xls spreadsheet2400.xls how can I use file globbing to select files that numbers end in ...
1
vote
0answers
61 views

Cron deamon written in shell

I'm looking for a script in bash or ksh, that would do ... more or less ... the same as crond. The situation is, that our system administrator suddenly denied the use of crontab to all regular users ...
0
votes
1answer
738 views

Issues with this sh script?

Having issues executing this sh script...i don't see anything wrong with it, does someone else see something I screwed up? echo "**************************************" echo "*** ...
0
votes
1answer
274 views

How to delete a line from a file that requires permission such as visudo using sed?

I want to add this command timestamp=20 at the end of visudo file which will increase the sudo time for 20 min. This way I'll be able to use my bash script to install many applications. After I am ...
1
vote
1answer
80 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?
-2
votes
1answer
107 views

On telnet session file edit not happening using vi editor

I used rlwrap because with telnet session arrow keys were not working, after starting telnet session with rlwrap am not able to edit the file in using vi editor. Whether its problem with rlwrap.If i ...
1
vote
1answer
832 views

How to create destination directory structure dynamically when using mv with wildcards in bash?

I'm pretty new to BASH scripting and I'm looking for an elegant way to solve my task: In a given directory certain files regularly have to be sorted into subfolders. The name of the files has a fixed ...
1
vote
1answer
126 views

recursive diff of files case-insensitive

How do I run a recursive diff when the filenames are the same but have different cases? For instance: ./Root/Directory/FileName.txt ./Branch/directory/filename.txt diff -r -i Root Branch only ...
3
votes
2answers
1k views

ls with glob not working in a bash script

I need to list all the sub directories of a directory excluding those that match any of a list given as an argument: "SUBDIR1,SUBDIR2,...,SUBDIRN". I came with the solution (from many sources) of ...
0
votes
0answers
90 views

Ubuntu: `env -i bash --norc`, but include essential variables such as HOME, DISPLAY? (where are these set?)

Is there an easy way to isolate a session of bash so that only essential variables (HOME, USER, DISPLAY, etc.) are preserved? (essential in that many programs fail if HOME, DISPLAY, TERM, SHELL, etc. ...
0
votes
3answers
292 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 ...
0
votes
3answers
66 views

Rename files by trimming the '\n' at the end of their name

I made a python script to parse a large volume of some data and save the results which ended up producing ~162 files. The script named these files Parsed_NameOfOriginal\n. Notice the \n at the end ...
1
vote
2answers
87 views

Keystroke to clear the current line at the prompt

How can the current line be cleared? I'm using bash. I don't like ctrl+c because it leaves crap printed on the screen. If the cursor is at the end of the line I can use ctrl+u and it does ...
0
votes
1answer
33 views

read switches usually in while loop

I want to know the usage of read switches with some good examples. as instance I know about -t -s -p switches: -t: he -t option followed by a number of seconds provides an automatic timeout for the ...
1
vote
1answer
99 views

How to restore virtual host configuration on Mac OSX

I successfully created some virtual hosts on my machine a while ago by modifying my /etc/hosts file and my http-vhosts.conf file. Then I found a very handy tool called virtualhost.sh ...
0
votes
0answers
335 views

Terminal: Multi-column/Table 'ls'

When running a fullscreen terminal, ls doesn't adapt to the current terminal width and supply me with multiple column-listings of items, it always provide a single column of directory items. Even ...
2
votes
4answers
2k views

bash - remove all directories (and contents) but not files in pwd

I'd like to remove all directories from the pwd but leave the files in the pwd alone. If the content of my pwd is: mydir1 mydir2 myfile1 myfile2 then I'd like to be left with just myfile1 myfile2 ...
2
votes
2answers
74 views

Is there a way to print 2 lines (if any) before and after a target or print a placeholder if not?

I'm not native english speaker so I hope to be clear. I know about grep -C 2 "TARGET" inputfile to select 2 rows before and after the row of the TARGET, but I'm not able to use it to manage my ...
1
vote
1answer
1k views

Bash - move files with similar name from multiple directories to pwd

Say I have directories: mydir1 mydir2 mydir3 mydir4 containing files starting with abcd I'd like to move all file beginning with abcd to the parent directory. How can I do this? Here's what I've ...
1
vote
2answers
491 views

replace file's content between specific line numbers with another file using BASH

What is the most efficient way to replace file's content between specific line numbers with another file? Here is a sample: main.txt: a b c d e f g h i j k l new.part.txt x y z p q r s t u The ...
0
votes
2answers
905 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 ...
0
votes
1answer
171 views

Restricting MSYS (Bash) auto-completion to current directory

I'm using MSYS on Windows 7 and I really enjoy the TAB auto-completion feature of the bash console. However it appears that this feature queries all directories in Windows' $PATH variable, requiring ...
1
vote
0answers
154 views

mergecap fails to create output file when run from crontab

I have created a script to merge pcap files using 'mergecap -w '. The script doesn't work as the output file is not already present. So I tried to use 'touch outputfile.pcap' before the mergecap ...
1
vote
3answers
196 views

How to select a section from a string in using bash

I have an array containing strings which consist of paths to files in the following format: /path/to/file/14561234545_50303.TXT I'm trying to select the section that is after the "1" but before the ...
1
vote
2answers
6k views

Mac Terminal showing bash instead of my username

This makes it hard to know what directory I am in. I installed a version of python for school and now it says -bash-3.2$ instead of MyMacbook: ~$. I'm sure this is really simple, but I know nothing ...
2
votes
2answers
497 views

bash is not deterministicly processing the asterisk wildcard

I accidentally added a user to my system without a home directory (I forgot to put the -d and -m flags in useradd). Rather than deleting the user and starting over I attempted to simply mkdir the home ...
1
vote
1answer
645 views

Download and Run script in Linux Terminal?

I am running Linux. I'm writing an installer in Bash for an application I wrote. The installer needs to be able to download different Bash scripts and run them automatically? How would I go about ...
1
vote
1answer
172 views

inotifywait get only on event when create directory

I want to run service to listen on directory modifying and for every add or file modify run a function but I get more one event from adding directory inotifywait -rm -e create,modify "$dir" | while ...
7
votes
2answers
477 views

What is the modification date ls reports for directories in Bash shell?

When I run ls -l in Bash shell, it lists a modification time for both files and directories. As noted in this thread, the modification time for directories does not reflect all of its contents. It ...
3
votes
2answers
2k views

How do I pipe output to date -d “value”?

I have a date like "2014-01-30 05:04:27 GMT", and if I run date -d "2014-01-30 05:04:27 GMT", the output is in my server's timezone ("Thu Jan 30 16:04:27 EST 2014"). With the use of grep and cut, I ...