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

learn more… | top users | synonyms

1
vote
2answers
792 views

How do I parse a Tiddlywiki into a bunch of plain text files?

I found a Tiddlywiki plugin to export all the tiddlers into one plain text file, but I want to take my Tiddlywiki file and export the individual tiddlers to individual text files (later to be migrated ...
6
votes
1answer
276 views

Why are some (often long) commands garbled in bash & zsh?

Many times when I enter a long command in bash or zsh (these are the only two shells I am positive I have seen this in) the cursor warps to somewhere in the middle of the string I am entering, can ...
0
votes
2answers
15 views

What's the smartest way to copy-rename (backup) several files in different folders at once in the shell?

I want to copy-backup several files in different folder at once before updating ntpd. Example (one file only): sudo cp /usr/sbin/ntpd /usr/sbin/ntpd.old Files: /usr/bin/sntp /usr/bin/ntp-keygen ...
1
vote
1answer
65 views

Bash script starts my program two times

I have a custom daemon program in C, which is a daemon. The usage is as follows SampleGame /directory1/ /directory2/ /directoryN/ I've made the same into a bash script. When I start it, the ps ...
0
votes
0answers
6 views

Staret managed server using Jenkins

I am trying to start web-logic managed server from Linux system. for that I have one shell script start_wls_managed4_btwnpmd01.sh with following code. ...
1
vote
1answer
12 views

Programmatically starting 6 servers and manipulating Gnome Terminal

I would like to make a script ( bash ) that will programmatically start gnome-termal with 6 tabs each with its own title start a different command in each tab delay starting server 5 until sever 4 ...
3
votes
3answers
81 views
+50

How do I find files and total their sizes?

I'd like to find a series of files (based on a wildcard expression) and total their disk usage. Something like this: $ find . -name 'flibble*' -ctime +90 -exec du -sh {} \; 2.1G ...
0
votes
2answers
31 views

Remove directory that is listed as “No such file or directory”

I have a folder on an external harddrive that has a curious folder in it that shows up as "No such file or directory" when I do a directory listing. See screenshot below. How do I remove this ...
1
vote
1answer
25 views

bash script processing files with bad characters

I received a zip file with a folder structure that include parenthesis. I've worked through two processes at the cli and now merge them into a script The first searches through the file structure for ...
1
vote
2answers
66 views

In VIM, how do you delete to end of line while in command mode :?

While in VIM, I have a leader shortcut for the following: :!git commit % -m 'updated '; git push; ...
4
votes
2answers
977 views

Download a file over HTTP with Bash only?

How would one go about downloading a file from the command line using Bash but not Wget or Curl?
1
vote
1answer
29 views

Is there a limit to how many “../” back-directory references you can make?

I've never noticed this before (and I've been using Linux as a primary OS since 2008). Is there a limit to how many back-directory references you can make with ../? Why? I moved a file only for it ...
1
vote
3answers
33 views

Bash rename music tracks

I have a folder with around 80 music tracks. I would like to rename them from "Artist - Title" to "01. Artist - Title" all the way through 80. I can't quite figure out how to do this, so could ...
1
vote
1answer
24 views

How to get different prompt look for root and regular user

My .bash_profile has different styles of prompt for regular user and root but in order it to work the .bash_profile should be reloaded every time I switch users. How can I achieve this? Can I make ...
41
votes
9answers
44k views

Remove a certain line from Bash history file

How can I remove a certain line from history's database?
7
votes
3answers
3k views

How to upload multiple files to FTP from linux server?

I have for example database backups in my linux server and I would like to write a script to upload it to remote FTP. I tried put command, but it can only transfer one file at a time. Then tried mput ...
4
votes
2answers
355 views

Why does this bash prompt sometimes keep part of previous commands when scrolling history?

My bash prompt, which I'll admit to have stolen from a few places and cobbled together, will sometimes add part of previous commands to its length when scrolling the bash history with up/down arrows. ...
0
votes
2answers
29 views

find /data/oozie-admi/ -type d -ctime +1 | xargs rm -rf [0] command deleted /data/oozie-admi/ folder

/data/oozie-admi/ folder contains multiple directories. This command find /data/oozie-admi/ -type d -ctime +1 | xargs rm -rf [0] deleted /data/oozie-admi/ folder . Need to find out scenarios in ...
1
vote
1answer
34 views

Why is my bash history not sorted by date?

My mac bash history looks like this (I'm copying just the last +100 lines): 2769 23/09/14 17:54:09nano ~/.bash_profile 2770 23/09/14 17:54:21nano ~/.bash_profile 2771 23/09/14 17:54:28source ...
0
votes
2answers
34 views

Command “find” -exec replacing string

I'm trying to find JPG files in a folder tree to execute the command "" to transform it to PDF. The problem is that the code I am running leaves the file in the same directory and I want to move it ...
-1
votes
0answers
29 views

Python script to create users and upload ssh keys to remote server from a local machine [on hold]

This is what I am trying to do. I have a user list csv file containing: user1, SSHkeys/user1.pub user2, SSHKey/user2.pub Store them respectively into $username and $SSHKey Another server list csv ...
1
vote
2answers
44 views

Can `ls` be set to only list the first X files/directories?

I'm trying to make a command which only displays the first 30 files when the ls command is invoked. I found this method... ls | head -30 ... but it ends up spitting out the files in one long list, ...
0
votes
2answers
2k views

Sending Mail on Linux via Bash/Command line

I'm currently trying to send mails via bash script on Linux. I searched the internet and found this code: echo "This is my body" | mail -s"this is my header" thisis@my.mail I don't get any ...
1
vote
2answers
22 views

Nmap runs slower as root than normal user

I am working on a bash script to enable automatic detection and remote control of my company's proprietary data recorders. The recorders run a custom version of linux and are essentially powerful pis ...
0
votes
0answers
17 views

Bash Terminal colors for filetypes [duplicate]

Bash terminal seems to not have colors for certain types of files, such as docx, pdf... Is it possible to add colors for these in the output of ls, or no?
0
votes
3answers
38 views

Find files then tar with wildcard

I have a series of files called: 2014111test.log 2014111test.log.stuff 2014111test.log.flibble 2014115test.log 2014115test.log.stuff 2014115test.log.flibble I want to find all the log files over a ...
0
votes
0answers
19 views

How to close a GUI window from BASH

I can open a GUI window from BASH with the following command: gnome-open /media/UPDATES How do I close it from BASH? (There is no "gnome-close" command.)
12
votes
8answers
10k views

Show only odd lines with cat

HI, probably is this something very easy, but I do not get the point now. In Linux, shell, given a text file, how can I do something like, cat filename so I only see the first line, the third line, ...
78
votes
9answers
37k views
13
votes
3answers
11k views

Get home directory by username

I want to obtain home dir of any user with echo echo ~puchuu >> /home/puchuu But I cant use variable echo ~$USER >> ~puchuu echo `echo ~$USER` >> ~puchuu
3
votes
6answers
146 views

How to match everything from after the last YAML delimiter onwards

I normally use grep to search for a pattern in a string. However in this particular instance I have to identify a YAML header, also, it ends with a triple dash. My test.info file has the following ...
1
vote
1answer
25 views

How to Extract Multiple substrings from Log FIle

I am trying to extract the timestamp and the number string in the URL called in an apache logfile that looks like this: 123.456.78.90 - - [16/Dec/2014:06:27:30 +0100] "GET ...
1
vote
2answers
265 views

MySQL database restore

I've written a script which backups my MySQL database and produces a GZIP file with the mysql dump of my database. I wondered if it's possible to decompress the GZIP file and restore the database in ...
-2
votes
1answer
115 views

Bash- how to select a directory based on the number of files it contains

I want to select all the sub-directories in a given folder that have a certain number (in this case, 75) files within them. Then I want to take the name of each of these sub-directories and assign it ...
1
vote
1answer
29 views

shell script file (.sh) - dynamic command

I'm trying to build a dynamic command to execute in an .sh file, however, when I do it, it seems that somehow it adds \r characters so command is not correctly executed. Notice that I'm running this ...
0
votes
1answer
13 views

Type file content, pipe some actions and put result back

Is there way to do something like thas: cat somefile.txt | sort | uniq > somefile.txt I.e. I want to list entire file, then pipe some actions to its content and finally put result back to source ...
7
votes
2answers
4k views

What is cmd's equivalent to Bash's & (ampersand) for running a command without waiting for it to terminate?

In bash: java -jar jarfile1.jar & java -jar jarfile2.jar & The ampersand lets you launch the first program, and then do another one while the first is still running. How do I do this in ...
1
vote
1answer
23 views

Linux bash, command replace

How can I erase the - from clipboard? I have a script: #!/bin/bash xclip -o | replace - "" | xclip Bat this doesn't work So replace \- "" take no effect ]$ uname -a Linux localhost.localdomain ...
7
votes
3answers
11k views

How can I get Mac OS X's proxy information in a Bash script?

I have several network locations set up on my laptop: Work, Home, etc. The work one(s) all have a proxy server set up, while the others don't. This works fine for OSX applications -- Safari, Mail, ...
0
votes
1answer
19 views

Up arrow in gnome terminal to review command line history ignores commands with leading whitespace. Is there a workaround?

When writing python code (using gvim) I often keep complex command line commands for test cases saved in my docstrings. A common time-wasting error I make is copying the entire line from the python ...
2
votes
1answer
39 views

Renaming multiple directories

If have a directory structure that stores records based on their date of recording. Originally there was one directory that contained a subdirectory for every single day like this basedir ...
3
votes
0answers
240 views

Bash auto-completion of variables adds additional white space at the end

when I perform an auto-completion of a bash variable an additional white space is added at the end. $FO[TAB] -> $FOO" " I added the quotes in order to denote the white space. The problem is ...
0
votes
1answer
31 views

conemu multiple bash cygwin ssh

I just want to know how to have multiple tabs logged in to a server via ssh to for example ssh user1@1.1.1.1 for a tab named server1 (to some particular folder location) and ssh user2@2.2.2.2 for a ...
0
votes
1answer
101 views

BASH: Bracketing Parameters

Simply, whats the fundamental difference between $param and ${param} ?
4
votes
5answers
2k views

xargs command works on ubuntu, but not mac

I have the following line of code that I use to update my personal date variable in my projects to today's current date. This line works in Ubuntu's terminal, but the Mac terminal seems to be far ...
1
vote
1answer
16 views

Get user logged into a given tty

I'm writing a bash script that disconnects idle sessions but writes to the tty a few seconds before terminating it to make sure it really is not being used. The format for write is write user [tty]. ...
0
votes
0answers
27 views

Shell command shortcut using input filename as output filename

Hi could someone help me with a little command shortcut please? Im trying to run an ffmpeg command and was wondering if there was a shorter way to type it, Ive been reading up on parameter expansion ...
0
votes
1answer
31 views

What does `-n` option in sed do?

This is the man page entry for -n: -n suppress automatic printing of pattern space I notice that when not using -n for certain operations, each line is printed to stdout (and the requested ...
1
vote
1answer
23 views

Grep fails to find sequence after assign to variable

I run: awk -F ',' '{print $2}' data.dat | sort | uniq | tr '\n' ',' | grep "*)>nS4XkrlH @XUL" and the sequence is located in results. Then I run b=`awk -F ',' '{print $2}' data.dat | sort | ...
2
votes
2answers
199 views

Why does the 'vi' command open 'vim' editor?

I am using Ubuntu 12.04. Not that I am complaining as I like my vim and prefer its many features. However, I’m curious as to why it does it. It is not aliased in .bashrc or .bash_profile. I am not ...