bash

How to grep a file using search parameters from another file

I am trying to use a file containing IP addresses as the basis for searching through a Cisco firewall configuration file. Normally, I would use something like: for i in $(cat ip.file); do grep $i fw.config; done But doing that returns absolutely nothing. If I put the above script into a file and execute it with the bash -xv flags, e...

Argument list too long. Building Hubbub HTML Parsing Library. execv

When I attempt to build this library on my system (Fedora) Linux localhost.localdomain 2.6.33.8-149.fc13.i686 #1 SMP Tue Aug 17 22:45:56 UTC 2010 i686 i686 i386 GNU/Linux I get a long list of errors of which this is the last few lines: build/makefiles/Makefile.top:542: warning: overriding commands for target `build-Linux-Linux-releas...

Modifying Apache config file using bash script

I'm currently writing a script to automate our CMS setup and deployment. Part of that process is adding an alias to Apache2 which is normally done manually via Webmin. At current, I'm looking to append a line into the Apache2 include file that stores all the alias, using the following: echo Alias /path \"/var/www/directory\" >> alias.i...

Shell script to sort lines by version and build numbers (line_5.4.3-2)

I have a text file with entries representing build tags with version and build number in the same format as debian packages like this: nimbox-apexer_1.0.0-12 nimbox-apexer_1.1.0-2 nimbox-apexer_1.1.0-1 nimbox-apexer_1.0.0-13 Using a shell script I need to sort the above list by 'version-build' and get the last line, which in the abov...

Bash: Testing if a variable is an integer

Hello, I have a bash scripting question please. I would like to test if my variable $var is actually an integer or not. How can I please do that? Thank you very much, Jary ...

What is an efficient workflow with C? - Makefile + bash script

I'm working on one of my first projects that will span more than one C file. For my first couple practice programs, I just wrote my code in main.c and compiled using gcc main.c -o main. This worked for me as I was learning. Now, I'm working on a much bigger project on my own. I want to continue doing compilation on my own (or at least s...

Sed / awk script to correct illegal characters from XML (ampersand)

For parsing an invalid XML file, having either unencoded, illegal characters (ampersands in my case): <url>http://example.com?param1=bad&amp;param2=ampersand&lt;/url&gt; and encoded ones <description> The good, the bad &amp; the ugly </description> Please post an example with a sed/awk script that can encode the illegal characters....

shell script + $? as deafult 1 in the begining

hi dear friends I have the following (part of big ksh script) while [[ $? -ne 0 ]] do print -n "ENTER VALID HOST IP" read IP CHECK_IP $IP # CHECK_IP is afuntion that check if IP is valid and return 0 or 1 done as we see in the while the $? is always equal to 0 so we cant ask for the IP the target of the loop...

How to change output filename if it originally is something else.

I have two files with different names. I have a for-loop to see if one file is there; if it is then it will change a file. My first thought was to make a list of all the files and what its counterpart is. That would not look nice and I can't cover all possibilities in the script. If this is the only way, how would I do it best? The scr...

Tcsh and Bash Initialization

I would like to be able to source a file to set up some environment variables, but do it so it's independent of the shell being used. For example %: source START.env # START.env if [ $SHELL == "bash" ]; then source START.env.bash # sets environment variables else source START.env.tcsh # sets environment variables fi However, t...

How to make tclsh to ignore EOF?

At csh you can do set ignoreeof or at bash tou can do export ignoreeof=1 and this will make csh/bash to ignore EOF, i.e. it will not exit on Ctrl+D, or when it reaches the end or file. Is there a way to make the same with tclsh ? Is there a way to make tclsh not to exit when it reaches the end of file ? ...

Running interactive shell script in name of other user

In my shell script (bash) I want to call other shell scripts. I run my script as user_A. One of these scripts needs special handling: It has to be run as different user (user_B). Password needed here. It is interactive, but not only asks questions but runs another script in name of another user (user_C) using su. I have to enter a pass...

Recursive grep for bash in cygwin

if i want an alias to do "rgrep pattern *" to search all files from my current location down through any sub directories, what is an alias for rgrep I can add to my bashrc file? i would also like it to ignore errors and only report positive hits ...

How can I tarball the proc file system?

I would like to take a snapshot of my entire proc file system, and save it in a tarball (or in the worst case concatenate all of the text files together into a single text file). But when I run: tar -c /proc I get a segfault. What's the best way to do this? Should I set up some kind of recursive walk through each file? I only have...

Git log tabular formatting

Hello, I have a simple alias to display few last commits: log --pretty=format:'%h %an %s' -10 How can I make the results to be displayed in columns, like this: 898e8789 Author1 Commit message here 803e8759 Other Author name Commit message here ...

Bash script to extract entries form log file based on dates specified in another file?

I've got a pretty big comma-delimited CSV log file (>50000 rows, let's call it file1.csv) that looks something like this: field1,field2,MM-DD-YY HH:MM:SS,field4,field5... ... field1,field2,07-29-10 08:04:22.7,field4,field5... field1,field2,07-29-10 08:04:24.7,field4,field5... field1,field2,07-29-10 08:04:26.7,field4,field5... field1,fie...

how to append new text to specific text in a file, using BASH?

What is the best solution to appending new text after an existing block of text in a text file, using a BASH script? for example, I have a config file with the following: [setting1] ... [setting2] ... [setting3] I want to add some text after [setting2], e.g.: test1=data test2=data test3=data Therefore, I want it to look like t...

bash variable capture stderr and stdout separately or get exit value

Hi, I need to capture the output and error of a command in my bash script and know whether the command succeeded or not. At the moment, I am capturing both like this: output=$(mycommand 2>&1) I then need to check the exit value of mycommand. If it failed, I need to do some stuff with the output, if the command succeeded, I don't nee...

How to count number of non empty lines in a file using sed?

hi all how to find how many lines I have in file by sed (need to ignore spaces and empty lines) for example if I have file with 139 lines (line can include only one character) then sed should return 139 lidia ...

shell script + numbers sum

hi friends what the best simple elegant way to sum number in ksh or bash my example is about let command , but I want to find better way to summary all numbers for example num1=1232 num2=24 num3=444 . . . let SUM=$num1+num2+num3......... ...