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

learn more… | top users | synonyms

1
vote
1answer
21 views

Display the PID with bash scripting

Good day all, I am trying to write a bash script to show all processes of java, however i would like it to display in the below manner. ps -p $PID -o pid,vsz=MEMORY -o user,group=GROUP -o ...
1
vote
1answer
25 views

Evaluating false in bash with multiple commands without a subshell

Bash evaluates the logical operators such that && always takes precedence. So for example: false || echo 1 && echo 2 1 2 and true || echo 1 && echo 2 2 Ok. So lets say I ...
0
votes
2answers
24 views

Can gnu diff recursively compare only filenames in different folder structures?

I know that I can recursively compare two dirs with diff -qr and output only the differences. However, this appears to compare file positions within the trees (for example, /a/b/file01 != ...
0
votes
2answers
61 views

Executing Commands In Parallel That Never Finish

I'm attempting to run a few commands that never finish. These commands watch a directory and update files when they change. The idea is that I need multiple folders watched by different tools, able ...
0
votes
1answer
18 views

How to get bash history of already running session?

How to get bash history of already running session? 1.) I was thrown out of my server because of a cable fault. 2.) I logged in again using a new session. History of the other session is not ...
1
vote
2answers
27 views

Split multiple gz compressed files into even more files

I have a directory full of gz files. I need to split them into smaller ones, e.g. 1M of size. I do e.g. for one file: $ split --bytes=1m one_unzipped_file prefix_ but how to achieve for many ...
0
votes
2answers
100 views

Bash script that calls a program with some asterisks in arguments

I’ve spent last hour or so trying to write a pretty simple bash script and I never felt so dumb. So I have a list of strings (which are package selector specifications for a package manager, if that ...
1
vote
3answers
38 views

Copying multiple files on linux

I have a linux machine with folders named numerically. How can I securely copy ranges of these folders to another server? The source machine runs tcsh, the target bash. At the moment, from the ...
1
vote
1answer
33 views

Using the mv command with multiple wild cards

I'm still relatively new to Linux, so take it easy on a noob, eh? I have scripts set up to move media files to a specific directory based on its name. I used a wildcard to accomplish this, but I need ...
2
votes
2answers
28 views

Look around bash command history match

I got a match for Ctrl+R In bash. How do I go back and forth around that position? I have several commands that are run in sequence but I forget some of the commands names. Thank you!
0
votes
1answer
32 views

Passing different set of arguments to the different commands in a linux bash script

I am writing a bash script foo.sh that runs too commands bar with first input argument, and baz with the second argument: #! /bin/bash bar "$1" baz "$2" Now I want to make foo.sh more flexible, ...
1
vote
5answers
98 views

How to copy hidden (starting with a dot) files and subdirectories in linux?

How to copy hidden files and hidden subdirectories (the ones starting with a dot) in folder A to folder B? For example if I have this structure: A/a A/b A/.a A/.b/ A/.b/somefile A/.b/.c I would ...
0
votes
2answers
175 views

Update a sqlite database while select into a while loop

There is a bash script that will do "some magic"™ to files which will be referenced to a sqlite database and after doing "some magic"™ the database should be updated. Here are the simplified code ...
0
votes
1answer
70 views

sudo cp with wildcard syntax doesn't do anything in Linux

I have a directory containing files that are owned by root, from this directory I wish to copy all the files ending with errorAll to another directory. My wildcard syntax is correct because performing ...
0
votes
1answer
20 views

Keep screen running after starting it with an alias and running some commands

I have a bash alias to move into a project folder, start screen, and pull new changes from git. it looks like this: alias start_manager2='cd ~/programming/manager2/ && screen -t "main" ...
1
vote
1answer
60 views

How to use linux bash “sort” command in a portable script?

I am writing a bash script and I want to make it portable, to have the same results in the other computers. From this question I learned the system settings, like language settings and possibly other ...
0
votes
1answer
30 views

Unexpected result from sort command of linux bash

I have a file foo.txt with this content: chr1 15 chr11 5 chr11 8 chr1 7 chr2 23 chr1 35 I tried to sort it first according to the first column, and then according to the second ...
-1
votes
1answer
38 views

find all IDs and CLASSes used in an HTML document in BASH

I have a block of HTML that I need to pull all the IDs and CLASSes out of. Im wanting to make a list of these so that I can start trimming our larger then necessary CSS doc (173k). Ill isolate the ...
3
votes
2answers
55 views

How do you CD change directory into the absolute path of a symbolic linked directory?

I'm currently in a symbolic link directory and I want to go up one level in the absolute path, but I cant as it will hit me back up to my home directory (~). I can do pwd -P to get the absolute path, ...
3
votes
1answer
18 views

In bash, declare an alias that depends on current variable content

I would like to declare an alias in my .bash_profile that will use the content of a variable when the alias is used and not when it is declared. Ex: alias goSomeWhere="cd $BASE/somewhere" When ...
0
votes
1answer
39 views

Delete All files except specific file in bash [duplicate]

I am trying to use rm -rf !(current) delete all folders in current path except current folder. But I am getting below error bash: !: event not found How do I get this functionality in bash?
2
votes
1answer
48 views

Windows batch equivalent of bash's set -e

Is there a Windows batch equivalent to bash's set -e, which causes the shell to exit immediately if a command fails with nonzero exit status (except in places where it's expected like in an if ...
0
votes
1answer
27 views

Kill browser tabs with Bash from younger to older

Hello i want to kill tabs from a browser(ex. chromium) by order from youngest to oldest. I used pkill -f -n -9 chromium but i want to use it in a while iteration with comparison to pkill's return ...
1
vote
2answers
61 views

What does ./ mean in Unix/Linux [duplicate]

This might look wrong, but I know that using ./ you are basically "BASH"ing your scripts in Linux/Unix environment. For Windows users, this is same as running an .exe file from command prompt. ...
1
vote
1answer
58 views

remove spurious ending spaces when copy pasting from emacs console mode?

Using emacs in console mode, I want to copy mouse selected text from emacs and paste it to another application (possibily another term). But emacs will add full spaces to the selection to fill the ...
0
votes
0answers
25 views

How is a basic daemon made on OSX?

I have an OSX system that I'd love to have some daemons set up on that will automate the updating of all of my console utilities. How would I go about creating and running such daemons? I'd also like ...
0
votes
1answer
26 views

Delete a file inside multiple ZIP archives on the OS X command line

I'm trying to delete files with specific extensions from multiple zip archives. For example I want to delete all .html files contained in the zip archives in the current path so I have tried this: ...
1
vote
2answers
80 views

Restarting process in CentOS if server restarts

I have a VPS with some Java applications (made with "Play Framework") running on ports 9000, 9001, 9002 and 9003. VPS Provider (iPage) happens to reboot servers unexpectedly from time to time, leaving ...
0
votes
1answer
30 views

cp: fts_open: No such file or directory / Why?

I have following bash script: #!/bin/bash echo "This script will copy all JPG files inside directory '~/temp/merged':"; pwd; read -r -p "Please confirm, that you want to copy all JPG files [y/N]" ...
0
votes
0answers
23 views

gfortran not working on my Mac OS X

I tried running gfortran on my Mac OS X, but it wouldn't work. When typing gfortran in the terminal I got the error -bash: gfortran: command not found. So I thought maybe my installation was not ...
0
votes
1answer
34 views

Combination of Echo and >> operator command

I was learning how to configure Django on OpenShift and got stuck with following commands. Can anyone help me to find out what operation is performed by these commands here and what can be its ...
-4
votes
1answer
38 views

Shell script for going through files and deleting or compressing them

List, one at a time, all files larger than 100K in the /home/username directory tree. Give the user the option to delete or compress the file, then proceed to show the next one. Write to a logfile ...
0
votes
1answer
47 views

Awk script to run a command based on condition using 'if'

I have a piece of code here that basically takes a file called 'srcip' (which is just a list of IP addresses) and compares it to my '~/db' file which is just a tab delimited IP HOSTNAME database of ...
0
votes
1answer
38 views

is there a way i can either insert a character into a line or substitute and arbitrary character with itself plus some other carachter(s) in sed?

like say i have a string of numbers that constitute a phone number and are like so ########## and i want to format them like : ###-###-#### insert only puts in new lines, and i dont know how to ...
1
vote
2answers
34 views

Alter output of every command

I'd like to know if there's any way of altering output of every command I execute in terminal. The purpose is to make the output formated for my markdown howto's. E.g. ls -la .*z #>-rw-r--r-- 1 ...
0
votes
2answers
40 views

linux cat into file including exiting code all from copy+paste

Can I print out a code to STDOUT that would mimic the behavior of Ctrl+c inside cat? E.g. I would like my script to print out the cat command followed by the content of the file like this: cat > ...
0
votes
0answers
17 views

Is “Lynx: can't access startfile” normal when I'm looking for broken links? I'm kinda desperate

I'm doing a script in bash for checking broken links, is it normal that the dialogue "Lynx: Can't access startfile" appears when I run the script? This is my code so far: #!/bin/bash ...
1
vote
1answer
50 views

How do I insert a constantly changing (dynamic) string from a text document into .conkyrc as an image path

I want to change the Clementine album art with each song. Essentially, I am trying to insert an image path in Conky that changes every few seconds. I have a script clementine.sh that runs every 5 ...
1
vote
4answers
79 views

Grep to filter gigantic CSV file

I'm dealing with a CSV file that contains over 2 million lines. Quite a big one. I need to use grep (or any better way) to retrieve the entire row if the value of the second column matches 'jpn' or ...
1
vote
1answer
69 views

echo “something” > file not working when sh script is being executed by remote PHP server

I've got a web-server with my hardcoded webpanel for Source server management and I've got my VPS on CentOS which doesn't really want to execute sh script when asked from remote server. Web-server ...
1
vote
1answer
37 views

Good way to bookmark/navigate relative directory paths?

I work on a linux system with bash 4.x where I frequently find myself navigating different copies of very deep (and large) file directory structures. However, in reality I only need to access a ...
0
votes
1answer
33 views

Creating a macro with .sh

so I would like to write a script that will be used in the following way. ./MakeMacro 1 The basic form of the script looks like this: #!/bin/sh ...
0
votes
2answers
47 views

How can I make bash cut and paste to the X selection?

In bash under an xterm, how can I get Ctrl-k / Ctrl-y to cut and paste to the X selection?
1
vote
2answers
33 views

reverse print without trailing

I have a bash file calling a dns zone and have piped out the fqdn which I need to output in reverse. The snippet below does that fine except I get a trialing . at the end which I don't want creating ...
0
votes
2answers
41 views

Perform Terminal Commands Without Opening the Terminal - Linux

Is there anyway, within Linux, to open a terminal or perform a terminal command (such as executing a script) without actually opening the terminal window. What i'd like to do is be able to execute a ...
1
vote
1answer
34 views

How to split and recombine stdout pipe in bash?

I am parsing text on the command line. How can I take the output of one command and use it in two places in the next command? some_command | head -n $( awk '/search_term/ {print FNR} ...
0
votes
1answer
27 views

Why do i get a file named history in each folder in bash?

For some reason I get a bash history file in each and every folder where I issue any command. The file is called history rather than the normal .bash_history. My .bash_profile has the following that ...
0
votes
0answers
44 views

Linux bash - Add alias from script without source(-ing) the script

Is it possible to write a script like #!/bin/bash alias foo="bar -options" and get the alias added to the running shell without source(-ing) the script source myscript will work, but just ...
1
vote
2answers
194 views

Why is “source <(cmd)” working but not “$(cmd)”

I want to have a script to call with params which adds some aliases to my current shell. The aliases have to be builded in respect to the calling parameters and the current directory from where I ...
1
vote
1answer
148 views

How can I run a bash script automatically?

I have a script named run.sh: #!/bin/bash cd /root/yowsup-master/src/ ./yowsup-cli --interactive no --wait --autoack --config config.example This script executes another script. I tried adding my ...