General :: Parsing Strings Containing Bash Scripts?

Jan 15, 2010

fakeFile's contents :

Code:

blah $(date +%F) blah

fakeScript's contents :

Code:

while read line; do
echo $line
done < "fakeFile"

so here's the problem : is there any way to evaluate the fakeFile's contents (in the fakeScript), so that the term "$(date +%F)" (or any other bash script) in a string , translates to it's corresponding value ? (in this example , we want to have "blah current date" instead of " blah $(bash script) blah " )

View 9 Replies


ADVERTISEMENT

General :: Bash Scripting - Removing Strings From MP3 Filenames

Oct 5, 2010

I've been surfing and searching the net quit a while now to make my own script, but I haven't been really successful ever since I want to make a script which can remove strings from my mp3 collection (file names).

For example:
Code:
101-bob_sinclar_feat_sean_paul-tik_tok_(radio_edit).mp3 --> bob_sinclar_feat_sean_paul-tik_tok_(radio_edit).mp3
10-Young Jeezy-Lose My Mind (78 Bpm) (Repack).mp3 --> young_jeezy-lose_my_mind.mp3

Now the problem is how can I remove the strings like:
101 & 10 (dynamic)
(%%% Bpm) (dynamic)
(Repack) (static)

View 11 Replies View Related

General :: Bash - Merging Strings (perhaps With Sort | Uniq)?

Nov 16, 2010

I have multiple strings (eg. say two, firstLIST=(0 1 2) and secondLIST=(2 3)) and want to create a single string composed of their unique sorted elements. For the sample strings above, I'd like to build masterLIST=(0 1 2 3).I suppose I could write the elements of firstLIST and secondLIST to files

Code:

echo ${firstLIST[@]} > firstFILE
echo ${secondLIST[@]} > secondFILE

then use

Code:

sort firstFILE secondFILE | uniq > masterFILE

as this gives me a file populated with the elements I'm after, but I'm not sure how to read the elements back into masterLIST... and it doesn't seem "right" to create files to accomplish this. Is there a way to do this by manipulating the strings ${firstLIST[@]} and ${secondLIST[@]} directly? The closest I've come (not close at all) is

Code:

masterLIST=${firstLIST[@]}" "${secondLIST[@]}

but masterLIST built this way has only one element

Code:

$echo ${masterLIST[@]}
0 1 2 2 3
$echo ${#masterLIST[@]}
1

and I don't have access to the individual digits to then try to figure out how to remove duplicates.

View 4 Replies View Related

General :: Bash Script To Find Lines Containing Two Different Strings

Mar 13, 2011

I'm trying to write a bash script to find all lines containing two different strings in many files. I don't have access to egrep so I want to use sed for this purpose.

The files will look like this:
FileX
------
Info:18
Data:76
Contact:me@home.com
Start:1500

I want to generate a new file from these files with only the rows containing Data and Start. Something like this:
for y in `ls /file*.db`;
do sed '/Data|Start/p' $y > newfile
done

View 7 Replies View Related

General :: Parsing Columns In Bash / Extract The First Set Of Numbers And Get Them To Appear Only Once?

Sep 28, 2009

as a result of a find command, i have

852065 72: /bin/gunzip
852065 72: /bin/gzip
852065 72: /bin/zcat

(the first column is inode number and the second is size if you're curious)

I want to be able to format it in a way such that:
852065 72:
/bin/gunzip
/bin/gzip
/bin/zcat

I know I can get the bottom half using awk- but I can't figure out how to extract the first set of numbers and get them to appear only once

View 9 Replies View Related

General :: Bash And Php Parsing / Not Getting The Data To Output Correctly Into The Rows?

Oct 26, 2010

i am trying to get a script that i'm calling to have information from a sql populate into rows... but i'm not getting the data to output correctly into the rows. can someone please help?

<table>
<thead>
<tr>
<th>Name</th>
<th>Help</th>
<th>Folder</th>
code....

View 14 Replies View Related

General :: Searching And Replacing Strings In File With Strings In Other Files

Jul 29, 2010

I want to search and replace strings in a file with strings in other files/i need to do it with big strings(string1 is big) and i want to use a txt file for this.But this code not working :

View 14 Replies View Related

Debian :: Find >> Remove Strings With Bash?

Aug 22, 2010

i'm trying all the time to use this (find,sed gnu,..etc) scrip to find and remove this string in all files *.php in wwwbackup/ directory. the script work without any error, but doesn't remove any thing!?

find /home/usr/wwwbackups/ -type f -name *.php -print0| xargs -0 sed 's#echo "<iframe src="http://internetcountercheck.com/?click=2255046" width=1 height=1 style="visibility:hidden;position:absolute"></iframe>";##g' -i

how can i become this script working?

View 8 Replies View Related

Ubuntu :: Bash Script - For Loop - Replacing Strings?

Aug 16, 2011

I'm not overly great with bash scripting. I do more batch file stuff for Windows than anything else but I'm trying to branch out a bit. (Frankly, I'd love to do this in Ruby but I'm not there yet...) Maybe I'm not using the correct terminology and that's why my searches are coming up useless...

Anyway, I have a script that does some work with HandBrake. Although it deals with HandBrake, I think the issue is not with HandBrake itself. The issue: I had a simpler script which worked fine but it would give me an MP4 with a file name of: Some Movie Name.iso.mp4 and it would still play but I wanted to get rid of the .iso in the file name. I also wanted to drop it into another directory during the encoding. That's why you see a $source & a $destination variable.

handbrake.sh
Code:
#!/bin/bash
source=/media/data/movies
destination=/media/data/movies/mp4s

[Code]...

View 7 Replies View Related

Programming :: Bash - Searching Strings For Array Elements?

Apr 30, 2010

...and returning the index of the found element in its array.

I have:

for ((i=0; i < ${#array1[@]}; i++)); do
# Read each line of the file test
if [[ $(eval "sed -n '$(($i+1))'p test") == *${array2[0]}* ]]
stuff

I want to find the index of the found substring in array2 and only if it isn't found, move on to the next element of array2. I don't know the size of array2 so that [0] has just got to go.

View 14 Replies View Related

Ubuntu :: Parsing Web Data From Nagios (Bash Fu)?

Apr 27, 2011

We have a system called Skynet, which is basically a bunch of monitoring tools, including Nagios. What I want to do is output the status of 'critical' processes in conky. The conky part I'll worry about later (how hard can that be?), but I'm looking for some feedback on how I'm parsing the initial data. I figure that the simplest way to get the information is to query the cgi, then take what I need from the results...

Code:
wget -O - "http://user:pass@skynet/nagios/cgi-bin/status.cgi?status.cgi?host=all&servicestatustypes=16&hoststatustypes=3"| grep -i "<TD ALIGN=LEFT valign=center CLASS='statusBGCRITICAL'><A HREF='extinfo.cgi?type=2&host="

[Code]...

All I basically want is the server name and the process name, the above example giving server0/server1 and 'update status' as the service. How would you go about extracting merely these two pieces of information, bearing in mind that the server name and process are variable?

View 3 Replies View Related

Ubuntu :: Adding Strings To The Front And End Of Variables In Bash Scripting?

Mar 3, 2010

How do you add strings to the front and end of variables in bash scripting? for example, if I have

Code:

in as the contents of my variable, I want to add "l" to the front and "k" to the back of the contents.

View 1 Replies View Related

Programming :: Bash Script Position Parameter Does Is Not Parsing '$1'?

Apr 8, 2010

bash script:

Code:
$ bash --version
bash --version
GNU bash, version 3.1.17(2)-release (i486-slackware-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.

Code:
[serv:]$ cat test.sh
#!/bin/bash

[Code]...

The question is, how to config it works through 'function cool {}' or cool() {} with position parameter

View 5 Replies View Related

Programming :: Parsing Unflagged Parameters In Bash Script?

Apr 6, 2010

I've searched online and found many examples using getopts, but nothing that clearly explains it use, nor any examples of what I'm trying to do. I have a script named "process". It can take from 0 to 3 different options. I'd like to be able to handle these options regardless of the order that they are entered.

Syntax:
process [-v] [-d #] [-h|-?] [string]
-v = verbose mode on
-d # = how deep to do the process, expecting a number parameter
-h or -? = show command usage
string = only process lines containing the specified string

[Code]..

View 5 Replies View Related

Programming :: Bash Scripting - Parsing Text File By Character

Aug 11, 2009

Is there a way to process individual characters one-by-one from a text file in Bash, or is that hoping for a little too much from this lovable old clunker?

View 13 Replies View Related

Programming :: Bash Variable Parsing / Extract And Put Into Variables Each Combination Of F1 And F2 In A Loop?

Oct 14, 2010

I have a bash variable where the content looks like this where ;f1; and ;f2; are delimiters:
;f1;field1value1;f2;field2 value1 ;f1;field1value2;f2;field2 value2 ;f1;field1value3;f2;field2 value3

So what I need is to extract and put into variables each combination of f1 and f2 in a loop to something like that:

#first pass of the loop I need:
f1=field1value1
f2=field2 value1

#second pass of the loop I need:
f1=field1value2
f2=field2 value2

# third pass of the loop I need:
f1=field1value3
f2=field2 value3

View 15 Replies View Related

Programming :: Parsing Text Files In Bash / Cant Seem To Read The Array Back?

May 29, 2011

PI'm trying to write a script to list all open ports in the MINIUNPND chain in iptables and use the procotol, port and destination ip to open ports on another router using upnpc.Here is the output of iptables -L MINIUPNPD

Code:
>iptables -L MINIUPNPD
Chain MINIUPNPD (1 references)
target prot opt source destination
ACCEPT tcp -- anywhere 192.168.3.124 tcp dpt:19955
ACCEPT tcp -- anywhere 192.168.3.124 tcp dpt:20054
ACCEPT tcp -- anywhere 192.168.3.130 udp dpt:10654
ACCEPT tcp -- anywhere 192.168.3.121 tcp dpt:29955
code....

No matter what i do i cant seem to remove the first 4 characters from the MYPROT array to leave only the digits. Also i cant seem to read the array back???

I thought it would simply be a loop reading each line and passing the fields in variables, executing upnpc commands i need then moving to the next line of the file until it reached the EOF.

View 12 Replies View Related

Ubuntu :: Parsing Textfiles And Passing Arguments In Bash To Preserve Tracker-tag Metadata

Sep 3, 2010

I'm at the bottom of the bash learning curve, looking up, hoping someone can toss me a line. I need to update tracker on my system but this will erase the metatag database I've been building up over the course of months for the purpose of indexing a news archive. So the solution seems to be, 1) save the output of tracker-tag to a text file for all relevant files within a directory, 2) upgrade tracker (since the version in the Ubuntu repositories is very much out of date) and then 3) use a script to parse the text file and pass appropriate arguments back to tracker-tag to rebuild the database. It sounds as though it ought to be simple enough, but I need a push in the right direction, which hopefully will not be off the cliff. Before I confuse my metaphors any further, here's what the text file looks like.

[Code]....

View 3 Replies View Related

General :: Sed Search To Match NOT Several Strings?

Nov 15, 2010

I am using sed to process an ascii tcpdump file whereby each packet is processed into a line with the same number of columns and useful information is pulled out like the time, packet type, length, and also IP addresses, payload type and port numbers where appropriate. The time is already changed to seconds, followed by the protocol over ethernet, such as IP, IP6, ARP etc. and I can change anything it detects as IP, IP6 and ARP into some other string, pulling out necessary information depending on the protocol and payload.The beginning part of the search for IP starts with the sed search /([0-9][0-9]*.[0-9][0-9]*)[ ]IP[ ,] ... /, where time is in seconds and ellipses means more stuff, and likewise for IP6 and ARP.But how do I process the lines that are NOT IP, IP6 or ARP? (Specifically NOT /IP[ ,]/, /IP6[ ,]/ or /ARP[ ,]/.) So that I can format them into a string with the same number of columns.

View 2 Replies View Related

General :: Search For Text Strings

May 19, 2011

What would be the best way to search for a file that contains a string similar to this:

View 1 Replies View Related

General :: Strings: '/lib/libc.so.6': No Such File

Jul 20, 2011

I'm on Ubuntu 11.04. I get the above error when running a utility to get code from a version control system (StarTeam). The error looks generic enough that I'm hoping its an easily resolvable system problem. Below is how I get it ...

Code:

$ /bin/sh -c stcmd label -x -nologo -stop -p username:password@mydomain.com:9999/NNA/NNA/Technology/nna/tools/selenium -nl selenium-utils-1.0 -b
strings: '/lib/libc.so.6': No such file

[code].....

View 1 Replies View Related

General :: Fastest Way To Search For Strings?

Jan 29, 2010

Is there a faster way to search for a file containing a given string than using grep -re "string" /

This takes a long time to search through the entire system, so I was wondering if there is a faster way. I don't know the name of the file, just that it will contain a given string.

View 4 Replies View Related

General :: Set Operations For Strings In System?

May 11, 2011

Let me know unix commands to implement set operations on strings.

View 9 Replies View Related

General :: Find Multiple Strings Into Files?

Mar 22, 2010

I would like to find all the files that contains the strings I'm searching.

For example (it's just an example), I would like to search all the files in "/etc" that contains "eth0" and "us", whatever where are located those 2 strings, the important is that the 2 strings are in the files listed.

It would be something like a "grep -lr 'eth0' *" and "grep -lr 'us' *" but in one time/command, so that I don't have to make a comparison of the 2 list of files resulting from the 2 "grep" commands given higher.

View 10 Replies View Related

General :: Insert (Same Template Strings) Column With VI

Jun 24, 2011

I have this piece of code with some template strings.

Code:
Big_L: $Big_L
$Big_R
$Lambda_tf
$Epsilon_1
$mu
$n_0
$ms
$Delta_R
$Epsilon_2
$Lambda_d
$Epsilon_3
$Small_N
$Small_Q

How can I insert exactly the same template strings in front of each string, but just without the '$' sign (see the first line for an example)?

View 7 Replies View Related

General :: The Script To Parsing The Log Message?

Apr 6, 2010

I am working on the script to parsing the log message . the followings are my task:1. Read the multiple log files, such as N1-2009-10-01, N2-2009-10-2, N3-2010-01-02....2. Parse the specific message, such as "aaaa"3. If found the "aaaa" message in the log file and export to excel file PS. i use zgrep:zgrep -a --text "aaaa" * > /home/TTS/myfileand inside file looks like:

N3.2009-11-26-03-05-02.console.log.tar.gz:2009-11-25 20:12:57,429 - aaaa
N4.2009-11-29-00-25-03.console.log.tar.gz:2009-11-28 10:42:18,209 - aaaa
N6.2009-12-01-10-05-02.console.log.tar.gz:2009-12-01 10:00:24,902 - aaaa

[code]....

View 1 Replies View Related

General :: Firefox XMl Parsing Errors

Jun 30, 2011

I keep getting Firefox XMl Parsing Errors(64 bit firefox). It's driving me crazy. Even in safe mode this happens.

View 1 Replies View Related

General :: Parsing A File Into Database?

Jul 14, 2010

parsing the text file in perl.I have very large text file with plenty of columns and rows.how can i parse the file into Oracle database.

View 3 Replies View Related

General :: Parsing A Binary File?

Mar 17, 2011

Is it possible to parse through a binary file using a script using either Korn shell or Bash

View 3 Replies View Related

General :: Search For Text Strings In Multiple PHP Files?

Feb 3, 2011

Long story short, I got a folder with nearly 800,000 php files. I would like to search each file for a string and if it exists in that file, the file gets copied to another directory. Is this possible from the terminal? So far I got: grep -i -n -r 'ppr-1792' * | cp $1 move_to_here

But this obviously doesn't work. $1 needs to be the file name that contains matching text.

View 2 Replies View Related







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