Questions for bash


8991

How to write a bash script to set global environment variable?

Recently I wrote a script which sets an environment variable, take a look:
6983

How to get the percent of packets received from Ping in bash?

When pinging a host I want my output just to show the percentage of packets (5 sent) received. I assume I need to use grep somehow but I can't figure out how (I'm new to bash programming). Here is ...
1818

Linux scripting: hiding user input on terminal

I have bash script like the following:
1355

Why does this sed command not match whitespace?

This bash script is supposed to remove leading whitespace from grep results:
3769

loop over directory and file bash script - awk does not write to file

I would like to traverse through some directories that contain xml files. To each file I would like to apply an awk command and write the output to the file again. The file that is written is empty,
7927

What's the best way to check that environment variables are set in Unix shellscript

I've got a few Unix shell scripts where I need to check that certain environment variables are set before I start doing stuff, so I do this sort of thing:
9421

In Mac's terminal, can we have the command line arguments that are 'options' to the end of command?

Sorry if the title is bewildering. Let me illustrate by an example.
5674

Scripting language choice for initial performance

I have a small lightweight application that is used as part of a larger solution. Currently it is written in C but I am looking to rewrite it using a cross-platform scripting language. The solution...
8364

Check if a makefile exists before including it

I have a makefile that includes a Rules.mak file that holds includes to tools I want to use. Problem is that the tools folder has free options if they want to extract a version or use the "native"
7026

POSIX “sort -n” alpha characters between zero and 1?

I'm having trouble getting POSIX "sort" to behave the way I want it to. When sorting numeric file names, those that start with letters show up between 0 and 1.
5015

Script is re-reading arguments

When I supply the script with the argument: hi[123].txt it will do exactly what I want.
1933

printf “columns” and newline

In my program I'm trying to set up column headers for a file that I will be adding to throughout the script.
5873

Match all files under all nested directories with shell globbing

Is there a way to use shell Globbing to identify nested directories?
6712

Simple Bash - for f in *

Consider this simple loop:
2823

Regex remove comments but not shebang

I got a regex that removes the comments in bash using this regex code
3517

Git Pre-Commit Hook - No such file or directory

I am getting an error when running a pre-commit hook in git, that I can't figure out. This is the script and the error is below.
4120

Using ps2pdf correctly in a script?

I have a script below and I am having problems. I have several folders with PostScript file in them I want to batch convert to PDFs. I have done very little scripting in linux before but I think th...
2575

How to make ssh to kill remote process when I interrupt ssh itself?

In a bash script I execute a command on a remote machine through ssh. If user breaks the script by pressing Ctrl+C it only stops the script - not even ssh client. Moreover even if I kill ssh client...
1970

ANDing exit codes in bash

I have a bash script that runs three checks over my source code, and then exit 0 if all the commands succeeded, or exit 1 if any of them failed:
6753

Bash console tab-completion in Ubuntu

I used to develop in RedHat and never had the following problem until I switched to Ubuntu:
522

Bash: Getting input from a manifest

Is it possible too have a manifest file with directory strings, fx.
6045

Find for a class file in Linux that is present in JAR

I am trying to find a JAR file which contains my class using below command given in this link : Find a jar file given the class name?
463

Bash - Need to use exit but then call another function?

I'm writing a little script to use the webcam on the laptop and then email across the photo to me. The ffmpeg usage has to have a exit code for it to work so with this exit the mail function will n...
3922

Keeping track of history of commands of multiple sessions of ksh

I am using multiple sessions of ksh on a linux machine. On one terminal when I do history, I only see history of commands typed on that terminal.
8249

Fastest way to compare directory state, or hashing for fun and profit

We have a PHP application, and were thinking it might be advantageous to have the application know if there was a change in its makeup since the last execution. Mainly due to managing caches and su...
2681

How to make sure a script only runs after another script

I have two python scripts running as cronjobs.
6975

How do I pass variable inside find and bash -c?

Hey guys, I'm having issues with passing variable to %exe part of the code. Need your help.
1266

How can I use $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS

I wort a bash script it looks like this:
4138

Bash: wait for process to exit while tailing log file

In a bash script, I'm waiting on a child process's pid using wait. That child process is writing to a log file. Is there a way in the bash script to tail that log file to std out while at the same...
9436

How do I pass an absolute path to the adb command via git bash for windows?

I'm trying to pass a unix style path to the Android adb command using a git bash (msysgit) but the shell is interpreting my path incorrectly. This is what I've tried so far:
1183

While loop, how to read from second line of text file

i've tried everything for the past 2 hours to get this working but my experience in shell and programming is limited.
9481

BASH script - execute command with variable and store result

I don't know how execute a command with variable and get result of this.
7598

Making an alias for SSH MySQL login using ENDSSH heredoc

I want to make an alias that is kept in my bashrc file to log into a remote MySQL db via SSH.
5193

Syntax error near unexpected token “elif” in bash

Here's my code to display some dialogs.
7570

Bash variable scope

I want to search a repository file to see if I have a file in my directory. To do this, I loop the directory hopefully containing the file I am looking for, and I check to see if that file is in my
4166

Unable to delete Linux user using PHP and bash script

I'm able to delete linux users directly from the shell using the command ./del_user.sh
4664

if statement not evaluating correctly bash

I am testing if a variable is greater than another variable. The if evaluation is getting the same value no matter what the values are.
428

Assigning output of zenity to a variable

I have a script that makes a GUI list here:
1223

How can I append the name of a file to end of each line in that file?

I need to do the following for hundreds of files:
4207

Bash: Is it possible to change command before execution

I want to change the command so that command line flag(options) are placed before command line arguments, as which is done automatically by GNU getopt.
7162

why bash -l -c “CMD” makes ruby find my gem?

In my ruby script,I required the gmail gem:
5456

BASH: Using cut on space delimited file: Treating two spaces as one

I need to convert file full of lines like this:
1464

Python or Bash commands to determine time since a cron job string would have triggered

I'm writing a Django app (although parts can be Bash) that stores the cron job strings of many other machines. It needs to calculate the amount of time since that cron job would have triggered on ...
7237

Find duplicate records in large text file

I'm on a linux machine (Redhat) and I have an 11GB text file. Each line in the text file contains data for a single record and the first n characters of the line contains a unique identifier for the
4156

How to I export a system scope environment variable in bash

I need to set a system environment variable from a bash script that would be available outside of the current scope. So you would normally export environment variables like this:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.