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

learn more… | top users | synonyms

-1
votes
1answer
38 views

Can't understand loops :( [on hold]

I'm trying to understand better the while and until loops, can someone help me with this example? #!/bin/bash # Listing the planets. for planet in Mercury Venus Earth Mars Jupiter Saturn Uranus ...
0
votes
1answer
25 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 ...
-3
votes
1answer
26 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
17 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
32 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 ...
0
votes
2answers
30 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
27 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
6 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
15 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
35 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
23 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
23 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
21 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
24 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
29 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
29 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
19 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
24 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
36 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
181 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 ...
0
votes
1answer
39 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 ...
2
votes
1answer
36 views

Percent sign (%) in front of shell command

I just pasted a bunch of code into my shell, but forgot to remove the leading % before running the command. It appears to have done nothing. Why does this do nothing in my shell (zsh)? > % echo ...
0
votes
1answer
28 views

Linux find files in subdirectories by extension (.txz) then move them to specified directory using regular expressions

I have mirrored a directory from a server with a large number of sub directories, each of which contain a .txz package and the usual .txt and descriptor files. What I would like to do is the ...
1
vote
0answers
17 views

What triggers dropbox on fedora to upload files?

I am writing a computer simulation on a Fedora system, but wants to postprocess the data using MATLAB on a windows installation. My method for transferring files is Dropbox since the two computers are ...
0
votes
1answer
21 views

Is there a way to “source” a sh script from the fish shell?

I like to put many of my environment variable definitions in the .profile script. If I am using a POSIX-compatible interactive shell like bash, I can use the source command to re-export the ...
0
votes
1answer
15 views

Target directory structure for tar different than original directory structure

Is there any way to set a different target directory structure than the orignial directory structure the tar archive was created from without creating it by hand? For example, I have many files in a ...
0
votes
2answers
19 views

Move most recently modified file

I am trying to move the most recently modified file in "Pictures/". This is what I've tried: find Pictures/ -maxdepth 1 -type f -mmin -60 -print0|tail -1| xargs -0 -I {} mv "{}" Dropbox/somefolder/ ...
1
vote
2answers
34 views

Grep output from multiple lines in a limited shell environment

I have been scouring the web for ways to search across multiple lines of output and then print the lines which contain the strings I care about. I am actually running this on a checkpoint firewall, ...
0
votes
1answer
33 views

`if` statement with stdout && passing xargs through pipe

Say I have a list.txt of files I want to check. cat list.txt and for each file, I want to perform an action cat list.txt | xargs -I {} touch {} But depending on the outcome of the action, I want ...
3
votes
3answers
245 views

find command locking the system out

I had a folder , with 4+ million files in it. I managed to delete all files , in course of a week , using "find . -delete" and "kill -9" after a minute as it locks the system otherwise. now the ...
0
votes
0answers
7 views

Run xdg-open on mouseclick in a linux terminal emulator

I'd like the following functionality in a terminal emulator: after typing ls and pulling up a list of files, I'd like to be able to click on the file. This should runxdg-open on the file. This action ...
4
votes
1answer
251 views

Why does bash sometimes forget the command typed previously?

Came across a strange case on a Ubuntu Lucid system: bash command line is working fine most of the time, but for some reason sometimes Up doesn't work to recall previous command. It remembers the ...
0
votes
0answers
39 views

How to justify and center text in bash?

Newbie here. I'm looking for bash script to center and justify text. My script only works with one line of text. How would you improve it? #!/bin/bash COLS=$(tput cols) while true; do clear ...
2
votes
2answers
174 views

How to take control back on a separate process in Linux shell?

I just set up a Minecraft server on my VPS for my brother and I ran it with a bash script : sh ./server.sh& This way, the server is running and I can still work on the same command line with ...
0
votes
1answer
20 views

aptitude search something # print only package names, no extranea?

aptitude (the less-user-hostile wrapper on apt-get, for you oldsters), searches and prints too much when it finds packages. If I only want to see package names, what type? I suppose a clever cut ...
2
votes
1answer
52 views

Splitting video file into equivalent segments with ffmpeg

I have ffmpeg installed in my linux box. I am using it to split files into equivalent segments. So far I have test two approaches: 1. Create a bash script that grabs the file durationffprobe and then ...
0
votes
2answers
47 views

Accidently moved /* into another folder while in single user mode

My laptop has a bad gpu and while attempting to move AMD and ATI kext's out of /System/Library/Extensions I accidentally issued: mv /System/Library/Extensions/AMD * /Disabled_Extensions. The ...
0
votes
1answer
27 views

Can bash script be used to execute sequential and event-driven task?

I would like to know, and how a bash script can do tasks that need to be applied one after the other. Here is an example, I would like to install on my CentOS VPS the following softwares. $ yum ...
0
votes
1answer
31 views

Does Killing A Bash Process Affect Children Processes

The Scenario I'm automating backups via a bash script. The script is executed via cron. The script archives directories recursively using tar, and then rsync's them to the remote host. Here is a ...
0
votes
2answers
22 views

Write PID To File On Bash Execution

I'm executing a bash script via cron. I want to write the process id (PID) of the script to a /tmp/ file for reference, in case I need to kill it later on (this script can take 6 - 10 hours to ...
0
votes
1answer
21 views

Preserving newline in find/grep search results

I am recursively searching for the occurrence of php scripts being called from other files using the following script. find . -exec grep -Hn $1 {} \; | grep -v ^Binary; Works great! Now, I need ...
1
vote
0answers
51 views

Unexpected Bash glob completion uses first match even if ambiguous

If I have the following files in a directory: $ ls a-file-1 b-file-2 something-else And I type $ cat *file*<TAB> The line unexpectedly updates to $ cat a-file-1 | (pipe denotes cursor) ...
1
vote
1answer
38 views

Bash/Sed how to insert a string with special characters into a file

I have a script that I'm currently working on. And I've run into an issue where I need to prompt a user to enter a string, then encrypt that with sha-512, and then insert it into a specific file So ...
-1
votes
0answers
26 views

Rsync resume with Expect script after Broken pipe on remote server

I am trying to resume the RYSNC automatically with the expect script, but I keep getting error as I am not able to get into the expect script at all to enter the pwd My expect is installed in ...
0
votes
3answers
20 views

Auto-replace special characters in input / bash?

Let's say, I have the following in my .bashrc test1() { echo $@; } and I want the following to run in my terminal test1 1 and (2 and 3) which should output 1 and (2 and 3) But this just ...
1
vote
1answer
71 views

What is the difference between OS X and Linux filesystem? [closed]

When I go to the terminal in a Mac running OS X 10.something, which is everything now, the file hierarchy and naming scheme, especially when I cd to the root of the hierarchy it looks identical to ...
0
votes
2answers
23 views

How to do substitution in Bash

Well for example: i="Hello Bash" j=i I want to use $j to replace i like echo $$j So it prints "Hello Bash". Of course it doesn't work, but I hope you understand what the question is.
4
votes
1answer
163 views

Bash: Do something with every PDF in folder

I'm not familiar with the expansion of variables in bash. What I'm trying to do is: I got a folder with lots of PDF, which I want to shrink in size. The command for a PDF 'foo.pdf' would be: ...
3
votes
1answer
32 views

rename(1) a set of files beyond the current directory

The rename command in Ubuntu 12.04 (manpage says it's part of perl v5.14.2 2012-03-23) works well in a single directory, but I want to use it on subdirectories too (or, more generally, on a list of ...
0
votes
0answers
20 views

openSUSE server terminal showing missing .} after pressing enter without any command input

My openSUSE server terminal is showing a missing .} after pressing enter without any actual command input. I think it might be a bash version issue but how to confirm & solve as I searched and I ...