Programming :: Check If The Content Of A File Is "1"?

Feb 7, 2010

i want to close the program if the content of the file /tmp/file_name is 1 (just the number 1).

dont need to check all the time, just when start the program.

something like this:

Code:
"read the /tmp/file_name"
"check if the content of the file_name is 1"
"if not, do something"

what i need is very simple to do in shell script:

Code:
go=`cat /tmp/file_test` # "cat /tmp/file_test" read the content of the file_test
if [ "$go" -eq "1" ]; then # if the content of the file_test is 1
echo "ok, ready to exit now"; # now i can put the exit command
fi

but i dont know how to do the same thing in C...

View 11 Replies


ADVERTISEMENT

Programming :: Sed - Save Output To File With Filename From Content Of Another File?

Feb 28, 2011

My employer issues pdf files with everyones work schedules. I copy the content and save it as plain text in a file called unformatted (hope to be able to automate this step someday). Im working on a SED script that reduces unformatted to only display what I want to see and saves the result in a file Iïve named formatted. After that I have to manually copy formatted and save it with that days date as a filename e.g. 2011-02-25 or whatever day is scheduled in the pdf, for use on a mobile device (Nokia N900). I noticed that the date occurs on certain lines in the file so I added a line like:

sed -n 's/^Date: (201[1-9])/([0-1][0-9])/([0-3][0-9]).*/1-2-3/p' < unformatted >theDate
That creates a file theDate with the date in it that I wish to use as the filename for this particular instance. So I would like to skip the file formatted all together and have the sed- script write to a new file using the content of the Date as a filename, but how do I make that happen? And of course it would be more elegant if I could skip the intermediate theDate file as well.

View 4 Replies View Related

Programming :: Copy One File Content To Multiple File

May 28, 2010

I wanted to copy one file to multiple new files. I have an idea to write a script and do the operation. But here i m looking for any particular command to do this operation.

View 1 Replies View Related

Programming :: C - Can't Print In Screen The Content Of File

Mar 20, 2010

why this code can't print in the while loop the content of the file ?

Code:

#include <stdio.h>
int main()
{
FILE *fp;

[code]...

View 7 Replies View Related

Programming :: Display Content Of Txt File In Xbmc?

Apr 25, 2011

go about developing this add-on. i am testing this on my xbmc-live set-up; i am fairly affluent in bash/ c but unfortunately i dont have experience with python.i trimmed the data using this bash 1-liner so the output looks like:

Code:
xbmc@XBMCLive:~$ wget -q --output-document=- www.google.com/movies | sed -n 3p | tr '<' "
" | egrep "(title_bar|id=link_1_theater|class=info|mid=|Rated|class=times|fandango)" | grep

[code]...

View 2 Replies View Related

Programming :: Iterate The Content Of A File In The Shell Script?

May 29, 2010

i need to check group of URLs and there https requests from browser. Recently i got some command line web browsers to know the HTTPS status of the URL like curl, wget etc... Now all of i need to do is write a shell script. I will put all my URLs in a text file and my shell script should read each URL one by one and log the status along with the corresponding URL.

Sample output:

./myscript.sh url.txt
1. site - 200 OK

View 6 Replies View Related

Programming :: Remove Many Lines Based On Content Of Other File

Jun 21, 2011

I a csv-file (A.csv) with a total of 4.600.000 lines. Thats to many and only a few is necessary. I have a txt-file with 150 lines (X.txt) (all lines is dataset from a mainframe and looks like abc.def.123.456. How do I remove lines from A.csv where none of the dataset from x.txt is present?

View 13 Replies View Related

Programming :: How To Write Using Fwrite Without Affecting Existing Content Of File?

Oct 30, 2010

How can I write to a file multiple times using fwrite without affecting the previous writes?The method shown below accepts a file name, buffer and offset. The method opens the file in reading/writing mode and writes the content of the buffer at offset.

View 1 Replies View Related

Programming :: Lilypond Parser For Python - Typeset The Content Of File

Nov 12, 2009

I'm woring on a personal research project and would like to know if there are lilypond parsers for python available or I'll have to create my own. Just in case you are wondering: I don't need to typeset the content of the lilypond file, just understand what's written in the file (what notes, what duration, when in time to play each one, etc). [url]

View 1 Replies View Related

General :: Dividing Content Of One File By Content Of Another?

Apr 12, 2011

If you have the value 100 in File1 and the value 5 in File2, how do you write a script to divide the 100 in File1 by the 5 in File2 in Linux Bash Shell?The operating system I am using is Ubuntu 10 and object is to write a script to accomplish this task.

View 5 Replies View Related

Programming :: Check If File Contents In Another File?

Nov 4, 2009

i am trying to write a bash script. i have a text file called comp2.tmp which has a list of items in it

example comp2.tmp

Code:

filename.pdf
filename2.zip
filename3.ttf
and so on

I have another text file called comp1.tmp which should have the same list of files in it, but does not look as pretty

example comp1.tmp

Code:
someothertext here ...... 10/30/2009 ...... filename.pdf
=========================------------------==============
othertextagain .......... 09/28/2008 ...... filename2.zip
========================------------------===============
bunchmoretext ........... 04/12/2005 ....... filename3.ttf
and so on

i would like to check if the filenames listed in comp2.tmp exists in comp1.tmp

View 3 Replies View Related

Programming :: Check If Log File Is A Certain Size?

Mar 25, 2010

script that will check if my log file is a certain size? EX: I want to limit the size of my rsync log to say 5MB, if that's true I would move it and create a new one.

View 4 Replies View Related

Programming :: Check If There Is Any Ejb File Exists In The Directory

May 1, 2011

I have a directory called /data In this directory I have some files like abcejb.jar,12_ab_ejb.jar, shejb.jar, test I need a shell script like... 1st I want to check if there is any ejb file exists in the directory using some condition If ejb files exists I want to redirect the ejb files list to a file called list. Now I want to copy all the files in the list file to some remote system.

View 1 Replies View Related

Programming :: Check .xml File And Which Character Is Malformed In 'utf-8'?

Jun 15, 2011

I need some software that will check .xml file and tell me which character is malformed in 'utf-8'. I am using perl for some parsing.

View 2 Replies View Related

Programming :: Bash - Read Content Of File To Variable And Use This Variable In For Loop ?

Aug 21, 2009

I'm trying to read content of file to variable and use this variable in for loop. The problem is, when I have c++ comment style in file - /*. Spaces in line are also interpreted as separated lines.

For example:

Code:

Changing $files to "$files" eliminate these problems but causes that whole content of variable is treated as one string (one execution of loop).

View 6 Replies View Related

Programming :: Bash - Statement To Check If A File Exists Or Not?

Oct 6, 2010

This script that I found online does the job it promises. it does convert the files to mp3 without an issue. What I need to include now is an if statement that says If $file.mp3 exists then delete $file.wav

Code:
#!/bin/sh
# name of this script: wav2mp3.sh
# wav to mp3
# Credit to the script creator (Nikesh Jauhari):

[Code]...

After that I'm stumped as to how to do the if statement

View 14 Replies View Related

Programming :: Shell Script / How To Check File Size?

Jan 21, 2009

I have a file that's supposed to be growing in size 24/7. I want to check every 10 minutes via cron that it's actually growing. If not, send an email. Does anyone know how to write a script to do that?

View 3 Replies View Related

Programming :: Check That The Same File Exists Within Two Different Directories Using A Filename As A Variable?

Apr 30, 2010

I am in need of a way to check that the same file exists within two different directories using a filename as a variable. Here is the process which requires it: The script is reaches out (via ftp) and pulls down a file(s) and delete it afterwards. This is halfhazard because in the instance it doesnt pull down the file, yet still deletes it, we are up a creek. I am looking to pull it down to a temp location and then verify that file exists in the location in which it needs to be present to process before deleting it, adding a little extra layer for security. The script itself is finished.If I put a file name in manually it works perfect. I just need a way to pump the filename into the variable.

View 1 Replies View Related

Programming :: Write A Shell Script Which Will Check A File Name In A Dir And Copy It?

Apr 2, 2010

I am a novice to the shell script. In my system from db server the log files are enerating with the name log1.txt,log2.txt..... It is capable of keeping 10 files at a time in dir called /db/sis/log1.txt. I want to copy the log1.txt to another directory when ever it generating by attaching the time stamp to it for the back-up purpose. this files will be there for a period of 24 hours. after that the back-up dir should be cleared and it start copying again the fresh file from the same dir.

View 3 Replies View Related

Debian Programming :: Check If Files Exists By Read Input From A File

Jul 27, 2013

I need a script that dose the following checks if files exists by read input from a file then compares them to the files listed in the directory if they don’t exists the script would report back which file dose not exists. I also need to format the output so that files are grouped in different groups, group A, B, and C and etc based on file name. I would like the output of that do not exists files to be sorted based on second number in the file name than group according. I understand some of the basics of bash scripting something along of the lines of a loop and if statements might do the trick. Below is what I have so far. I don’t car so much about the script reporting back the file exists I prefer to only know if the file is missing and is less than 3 days old. Problem is if a file dose not exists in the reports file the test compares against the wrong file.

Group A

Foo22000.tar.gz
Foo22010.tar.gz

Group B

foo25000.tar.gz
foo25100.tar.gz

Group C

foo26000.tar.gz

Code] ....

View 2 Replies View Related

Programming :: Check Menu & Check List In Utility Dialog?

Aug 19, 2010

I want to put check menu & check list in utility dialog.i dont know how i do this

View 1 Replies View Related

Programming :: Bash Ambiguous Redirect - Redirect One Command Output Which Will Be Treat As A Content Of File For Another Command?

Mar 9, 2011

I am trying to grep multiple numbers from file, grep does have the -f option for that.

Code: grep -f <`seq 500 520` /etc/passwd I know this could be done with

Code: for i in `seq 500 520`; do grep "$i" /etc/passwd; done But my question is fare more behind this example. It is possible to redirect one command output which will be treat as a content of file for another command ?

View 2 Replies View Related

Debian :: Append File Content In Another File When Pattern Matches

Feb 5, 2010

I have a file, say abc.txt, whit some text lines.The I have a second file, say 123.txt where at a certain point one can read "WORD".I would like to append the whole content of abc.txt (as it appears in abc.txt) in the line after "WORD".

View 1 Replies View Related

General :: Searching Content Of The File Using File Browser Nautilus?

May 27, 2011

I'm using rhel6. Using File Browser Nautilus 2.28.4 I could easily locate any file I'm interested in by it name. I'd like to use this File Browser to locate the file name based on it content e.g. based on some word in the text file. It doesn't work for me that way ... My question: does Nautilus support the search of file based on it content or only based on the name of the file itself?

View 4 Replies View Related

Programming :: Read Content From Net In Python?

Jan 7, 2011

i made a program to read from a specific site whats on tv in that day.My question is if some of you have an idee how can i figure it out,what are movies,what are sports,what are shows ?

View 3 Replies View Related

Programming :: (PHP) Dynamic Or Static Content Generation

May 12, 2011

My project looks like this:

Home
The Team [no-page]
-X
-Y
-Z
Projects [no-page]
-Coding [no-page]
--A
--B
--C
-Desing [no-page]
--E
--F
-Security [no-page]
--G
--H

Note: the Code/Design/Security projects pages (A,B,C,D...) will be at start around 35 pages, and will grow. My index.php is something like this:
PHP Code: .....

What I would like to know is how to build the content (the home-main.php)? Do it dynamically based on a link something like this index.php?page=coding_b, and put in the index.php page a number of 35 if/else statements to cover all the project pages or ... static, creating every page for the projects menu when I create the menu? I check if a page 'pro-co-a.php' exists, if not I create it based on some template and do the query to get the content from db or? How to organize the pages, if using static page?

View 5 Replies View Related

Programming :: Can't Access To Content Of Array In For Loop

Mar 7, 2010

When I deal with an array in a function I con not access to the content of array in a for loop, but out of a for loop I can access to them! for example

[code]...

In a function when I send as parameter, in a for loop it prints the content of array and out of a for loop it prints the address of arr[i]

View 5 Replies View Related

Programming :: Unique The Content Within A String With Seperator?

May 17, 2011

I am green on linux script. I would like to perform the following operation:String a: 1,2,3,2,4,How to unique this string to become: 1,2,3,4,?

View 3 Replies View Related

Programming :: Use Echo To Display The Content Of A Variable?

Jan 4, 2010

I have a problem to use echo to display the content of a variable.

This is what I do:

Code:
#!/bin/bash
USAGE="Usage: name [OPTIONS] [DIRECTORIES]"
echo $USAGE

When I run this little script I get the following output:

Usage: name [OPTIONS] R

So I think that [DI might be some sort of escape sequence. But I do not know how to unescape it. Does anyone have a hint for me?

View 14 Replies View Related

General :: Find Will Go Through The Content Of Tarball As Well And List All Content

Oct 5, 2010

I am using find to search for .tgz files modified more than 7 days ago and delete them.find /directory/ -iname backup*.tgz -daystart -mtime +7 -exec rm -rf {} My problem is that find will go through the content of tarball as well and list all content. I want to only search main tarball and delete it if older than 7 days.

View 4 Replies View Related







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