Programming :: Using Loops In A Search?

Jan 21, 2010

Code:
Title=
echo -n "Title: "

[code]...

hey guys, im doing a simple search program and i came up with a problem. What i am trying to achieve is, if the search is false(means the book does exist) , the program will then ask the user to input the information again(title and author) and do a search again until there is no such book and then display a message saying he can input a new book in.i tried using a until loop, but it does not seem to work. some guidance on how the statement should be and where should it be placed?

View 4 Replies


ADVERTISEMENT

Programming :: Using Of Arrays In Loops?

Sep 3, 2009

need to process files within multiple directories and transfer these to a remote server. What I had in mind was to use arrays for this; code pasted below (explains it better):

Code:
#set the arrays
array_A=( fileA* pathtodestA hostA passwordA )

[code]...

View 8 Replies View Related

Programming :: Bash Unset Array Loops GARBAGE?

Jun 27, 2011

Code:

#loop until there are no more files
while [ ${#files[@]} -gt 0 ]; do
for num in `seq 1 ${#files[@]}`; do
wurd=`tail -4 ${files[$num-1]}`

[code].....

Everything works.. but when it has to unset.. it breaks.. it doesnt give an error though.. it just jams the program.

View 7 Replies View Related

Programming :: Loops In Bash Shell Or Variable Math?

Oct 28, 2010

I am trying to map the coordinates of a grid.

Code:

R=7 # number of rows (lines)
C=6 # number of columns
X=200 # initial horizontal location
Y=100 # initial vertical location

[code]....

View 4 Replies View Related

Programming :: Grep Search Between N-m

Oct 5, 2010

How can i use grep (or any other command) to check for lines that begin with N number.

E.g. I want to print out commands (from history), but only from the command number 50 until #200.

This one doesn't work:

Code:
history | grep "^[50-200]"
Should print out something like:
Code:
50 cd ~/Desktop

[Code].....

View 4 Replies View Related

Programming :: How To Search For A File?

Feb 3, 2010

How to search for a file? I am looking for a file in a directory /shared/domain...This also contains many sub directories..I need a script which will let me know the location of my log file myapps.log.what is the script ?Can it be made in one line ...because I just want to run ...don't want to save the script.

View 14 Replies View Related

Programming :: C++ Search And Handle Information

Sep 26, 2010

I would like to make program that reads a *.TXT file and searches for last line and constatly refreshing the search. So last line would look something like this:Mike Had A 100.0 Pound Shark.So there are multplie category of "fish"(Shark, Dolphin, etc.) and each of them have allowed weight (ie. minimum 70.0 Pound Shark, 50.0 Pound Dolphin). If in the found sentence Shark or Dolphin doesn't meet requierments than program named False.exe should be started. I dont know how to make it my self so any help is much appreciated. My knowledge on programming is very low but I'm opend for learning.

View 1 Replies View Related

Programming :: Get Search Results To Array By Awk?

May 5, 2010

I have this multiline variable code...

View 5 Replies View Related

Programming :: Recursive Search In A Tar.bz2 File?

Jul 14, 2011

I am looking for a one liner to search for a string in file(s) which are in a tar ball (.tar.bz2 in my case)

Code:
-bash-3.2$ tar -tjf /var/log/ABC/07142011-1412.tar.bz2
var/log/ABC/07142011-1412/
var/log/ABC/07142011-1412/live_hosts.txt
var/log/ABC/07142011-1412/all_hosts.txt
var/log/ABC/07142011-1412/LOGS.txt

How can I recursively look inside all the txt files in this tar file ?

View 10 Replies View Related

Programming :: Sed To Search And Insert Column?

Feb 24, 2011

I have the following file.

B0 49.2230869 -102.5743868
C 1LPRK 654.90
C 1PREU 3693.90
C 1JRSU 3693.90

[code]....

I need to insert text ABCDEF starting at position 26 if a line starts with C. I need it to look like:

C 1VKNG ABCDEF 3097.00
C 1JLFU ABCDEF 3157.20
C 1MNVL ABCDEF 3346.10

I would prefer to use sed to do this and not perl.

View 14 Replies View Related

Programming :: Using Sed To Search And Replace Backwards?

Oct 25, 2010

I'm trying to use sed to search and replace backwards. The problem is that I have a shell script that is required to put commas into big numbers. For example

9999999 as 9,999,999

I've tried a few things, but none seem to work:

Code:

$ echo 9999999 | sed -e 's/([0-9]{3})/,1/g'
,999,9999
$ echo 9999999 | sed -e 's/([0-9]{3})$/1,/g' -e 's/([0-9]{3})/1,/g'
999,999,9,
$ echo 9999999 | sed -e 's/([0-9]{3})$/1,/g' -e 's/([0-9]{3})/,1/g'

[ode]....

It would be much easier if I could search backwards! For example Bash parameter substitution style:

Code:
$ echo 9999999 | sed -e 's%([0-9]{3})%,1%g'

View 14 Replies View Related

Programming :: Gawk - Using Variable In Search Pattern?

Apr 4, 2010

yes, this is a homework question, but no - I'm not trying to get anyone to do it for me. I think that I am really close, but can't quite get one small aspect to work. in gawk, I want to include a variable name in the search string, but the below code doesn't work.

read -p 'Login name please? ' uLogName
userID=$(gawk -F: '/"$uLogName"/{print $3}' /etc/passwd)
echo $userID

[code]...

View 3 Replies View Related

Programming :: Search And Replace In A Binary File?

Aug 11, 2010

i need to change a binary file, let's say to find and replace username:

find string: "/home/name/bla-bla-bla/ "
new string: "/home/anewname/bla-bla-bla/ "

i can do it, for example, in emacs (hexl-mode), but interesting in writing a script instead. it will be much more better for me if i could do it automatically. is there an analog of: sed 's/string1/string2/g' ? P.S. the best way is to recompile the binary files i have, but there are no sources available.

View 5 Replies View Related

Programming :: Awk Multiple Line Search And Replace?

May 1, 2011

I am trying to search and replace a multi line pattern in a php file using awk.The pattern starts with

<div id="navbar">
and ends with
</div>

[code]...

View 3 Replies View Related

Programming :: Algorithm For Binary Frequency Search?

Jul 16, 2010

I've got a bit of an obscure question for you to test your brains a wee bit. I'm trying to implement a search program to find areas of high density in a binary string.

E.g.

Code:

[0001001010
0001110001
0000001000
1001000010
0101100100]

Where density is the number of 1's / number of digits with a maximum number of digits being the current number in a buffer (in this example 50). So for the example the density for the whole buffer is 15/50. But the density of Buffer[14..20]=[1110001]=4/7. So if looking for areas of density = 1/3 it would find the longest sequences of density over 1/3.So in the example. Buffer[4..9]=[100101]=3/6=1/2 which is above 1/3 but it is within the Buffer[4..48]=[100101000011100010000001000100100001001011001]=15/45=1/3

View 5 Replies View Related

Programming :: Awk Command - Search Pattern To Look For Last Occurrence

May 11, 2011

Any solution using awk/sed/regexp or other standard linux utility (this is for a mix of RH versions)? I am dealing with some very large application log files. I want to see everything that has been written to the log since the last application restart.

For an example take a log file like this:
Code:
# cat test.log
1 msg
2 msg
3 restart 1
4 msg
5 restart 2
6 msg

The following command is close to what I want:
Code:
# awk '/restart/,G' test.log
3 restart 1
4 msg
5 restart 2
6 msg

But the awk command grabs the first restart not the last. If it was working the way I wanted I would see something like this:
Code:
# awk '/restart/,G' test.log
5 restart 2
6 msg

So, I need something in that search pattern that says look for the last occurrence. I know how to do this with a pipe line - I could reverse the file and then do a similar awk and reverse back, or I could find the number associated with the last restart and then use that in the awk search. But these just take too long because the file is too big.

View 14 Replies View Related

Programming :: C++ Character Search In Text File?

Jun 23, 2011

Im trying to read a file in c++ and search for particular character for example if this is a list that I have:

Alice
Bob
David

[code]....

if the input is D, it should give David, if its B, gives bob. so in this case, meaning it reads the first character of every line. but if possible I want to make this dynamic so the user can specify which character position he is looking for, so in case he is looking for R as character index 3 in all lines, it should give Charlie. but the problem is, it does now recognize , besides, I do not know how to specify the character position in each line.

here is my code

Code:

#include <iostream>
#include <fstream>
#include <cstring>

[code]....

View 1 Replies View Related

Programming :: Force Repetitive Library Search Using G++ V3.2 On 3.9?

Sep 2, 2009

I have an application with a complex binary build procedure which links against 30+ application library archives and an array of system library archives. The problem I'm having is the link ordering. Is there a way to tell the g++ linker to keep searching the libraries for unresolved references, regardless of order, instead of rearranging the order the archives are listed on the command line for a one-time-pass? I'm using g++ 3.2.3 on a Linux AS v3update6 machine.

View 1 Replies View Related

Programming :: Search A String In The Files In The Subdirectories?

Mar 10, 2011

How can I search for a string (for example, a constant) in all the (.cpp) files in the current direcotire and subdiretories.

View 4 Replies View Related

Programming :: How To Transfer Search Output Between Two Server

May 25, 2011

I want to search for 1 file (say test.txt) on first server and all the output of this search to be greped as per my requirement and then transfered on the second server at the same location where they were on first server.

E.g.
output of search of file (test.txt) >> output.txt
/tmp/test.txt
/home/cpan/test.txt
/opt/cpanel/test.txt

Now I want to grep this output to only related to cpanel,
for f in 'cat output.txt'
echo $f | grep "cpanel"
if [ $? -eq 0 ]
then do scp.
But I am bit confused here, as in how to use scp command here.
scp $f root@second_server:/$f ?

View 3 Replies View Related

Programming :: Implementing Search Engine Optimization (SEO)

Mar 31, 2011

Though I have developed some web applications (automation tools) using PHP which have been primarily meant for Intranet (within the organizations I have worked for), I have paid little attention to SEO (it was not required until now). But now I want to understand how do we go about implementing SEO and where do we fit this mechanism in a system / website?

Do we need any other tools or learn some specific programming /scripting language to achieve it?Will implementing a good SEO yield identical results irrespective of what search engine (be it Google or Yahoo!) is being used by users?

View 1 Replies View Related

Programming :: Used The Output Of Search To Copy In Another Destination?

Dec 20, 2010

i want to used the output of search to copy in another destination examlpe. fine /home/* mtime -1 i want to used the output of the find command to copy an another destination

View 4 Replies View Related

Programming :: Search A String And Print Column?

Mar 13, 2010

I need to search a string which is in the first line and print that column.

For e.g

Code:
$ top -bn1 | head -20 | awk '/PID/,/*/'
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 13737 admin 15 0 2476 936 680 R 2 0.0 0:00.01

[Code]....

View 6 Replies View Related

Programming :: Search And Repalce A Char In Path Using Sed ?

Sep 1, 2009

I have the following path wher i want to replace forward slashes with back slashes using sed path=/temp/file.tar

I am using the following but it's not working.

View 3 Replies View Related

Programming :: Search For Ip Address In File And Remove It

Sep 22, 2009

I have a lot of files in the server with name like checkfile.jsp and in the file has two or three lines with an ip address xxx.xxx.xxx in it. I wish to know if there any command to grep for the i p address and remove itin file but keep the " ", eg "xxx.xxx.xxx"

View 9 Replies View Related

Programming :: Search The Count Values From The Dictionary?

Feb 1, 2011

I have written a code on Linux that searches a long dictionary. I have used hsearch() function but the problem is it does not work. This is my code://Search the count values from the dictionary.

Code:
#define _GNU_SOURCE
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<search.h>
#include<inttypes.h>
#include<math.h>

[Code]...

I open each DIC file, get the word from it and search the hash table and extract the key from it. The problem with the above code is that it is able to make the hash table but it returns NULL when searching. It should not return NULL in any case because all words from DIC files are there in the dictionary. I am not able to figure out why?

View 1 Replies View Related

Programming :: Sed Command Stuff - Search For Pattern?

Oct 3, 2010

I'm writing a script that edits a Maya ascii file. Inside the .MA(maya ascii file) there is a line defaultRenderGlobals. My script is supposed to find this line and according to what options they manipulate will update the lines below defaultRenderGlobals. I've got that working... but... the issue i'm having is that defaultRenderGlobals is only made when a the maya scene is made into a batch render. I want my script to manually addefaultRenderGlobals line into the .ma file if its not there and add the certain lines below it.RenderGlobals is already there I want to just manipulate whats below it. Hope this makes sense

View 2 Replies View Related

Programming :: Text Editor With Search And Capture

Dec 6, 2010

i was wondering if in all the editors/tools in linux, if there was a prog that can extract a portion of a text file, giving it a starting line of say o as the first character on a line of say o35565 oxxxxx then when it finds the next line down the file with the same thing oxxxxwhatever

it could take those lines and all the lines between them and save it to another file? i dont know if you call this parsing? or what.

View 14 Replies View Related

Programming :: Using File1 As List Of Objects To Search For In File2?

Aug 30, 2010

The goal is to auto-update a webpage that contains links to network devices. These devices are all set to DHCP, and their hostnames are not guaranteed to stay the same, so static IPs or accessing via hostname is NOT an option.

Process: Run a script every hour or so to query devices on the local network to generate a list of responding devices by MAC address and what their current IP is (results.lst). Using a "static" MAC address list file "printers.db" as the database search "results.lst" to find specific MAC addresses. When a match is found, grab the IP from "results.lst" and update "index.html" with the new IP address. No comparison needs to be done between "results.lst" IP and "index.html" IP as I just want to overwrite whatever is there.

Here is what I have so far (using dummy data): PRINTERS.DBProduct Mac Address Printer1 00:00:00:00:00:11 Printer2 00:00:00:00:11:11 Printer3 00:00:00:11:11:11 Printer4 00:00:11:11:11:11 Printer5 00:11:11:11:11:11 Printer6 11:11:11:11:11:11 TEST.SH

Code:

#!/bin/sh
#------------------------------
# Quick Links Updater v2.0 |
# By Rob M. |
# with help from Tim F. |
#------------------------------

[code]....

View 4 Replies View Related

Programming :: Specify A Library Search Path To Configure's AC_CHECK_LIB?

Aug 31, 2010

I'm writing an application and want to make possible to compile it with or without an optional module. This module requires perl library to be compiled, so I want to check presence of it in 'autoconf'.

The problem exists because perl library is placed in 'non-standart' location itself (like a /usr/lib64/perl5/CORE/libperl.so). So when I try to run configure (with AC_CHECK_LIB or AC_SEARCH_LIBS), it cannot find and link libperl.so in its test.

Trying to pass ./configure CFLAGS=-L/usr/lib64/perl5/CORE/ or ./configure LDFLAGS=-L/usr/lib64/perl5/CORE/

How can I define a location to search for configure's tests?

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved