Programming :: How To Organise Different Files
Sep 30, 2010organise different files into one by using linux programming?what is the use of gcc wat is its abbrevation?
View 2 Repliesorganise different files into one by using linux programming?what is the use of gcc wat is its abbrevation?
View 2 RepliesI found this command that works great finding and replacing a simple string to another in files located in that folder and all sub-folders.
Code: find . -name '*.php' | xargs perl -pi -e 's/OldText/NewText/g'
The problem I have is that I need to replace a more complex string, like this: Old string: /mnt/stor6-wc2-dfw1/627896/982574/ New string: /mnt/stor8-wc2-dfw1/369587/302589/ There I don't know how to do it... since the / is what separates the old from the new strings, and the strings that I want to replace have / in it. Also, I would like to know how to specify under what folder replace the files, for example, I want that it search/replaces all files under /var/www/mysite/htdocs folder.
I need a script that will take all the files in a given directory and create new monthly sub-directories and sort all the files based on the creation date into the appropriate directory.For example, all files created between 01/01/09 and 01/31/09 will be placed in 'JAN-2009'
View 5 Replies View RelatedIn my application I came across a new requirement where I have to convert RTF files to Word and PDF formatted files. I am searching for an API using which my java application can able to convert the above specified formats.
View 4 Replies View RelatedI need to rename the resulted searched files from a loopI have the following code:
find . -name DOC* | while read i
do
find $i -type f -name '*.txt'
done
basically, I am searching for all txt files inside any folder starting with DOC name.this code is working fine with me.I need to rename those .txt files to .txtOLDOS: Ubuntu 10.4Bash shell
When is it good to use separate translation units and object files and link them into the main C program, and when is it good to include the header files in the main C program? I don't understand if most people include header files or if most people just link in object files and use their contents in the main program. It's sort of a simple question, but it's confusing to me and that's why I need help with it. I sort of don't understand the difference, or if there's really no difference other than the way the final result is achieved, which way is better or preferred, etc...
For example:
Code:
or:
Code:
Simple explanation of the difference? or which one is preferred or better? I've read a little on the ELF format... so is there no difference in the end result? It's just a matter of preference or necessity, and where the information is to begin with?
am writing a small search program for my class. I have decided to use indexing for my program. Ive researched online about indexing and how search engines do it. If im gonno do that I need to create inverted files to associate files to numbers ( numbers being the index of my paths ) . Now I was wondering what would be the best way to create an inverted file ? I was going to create sql tables using mysql api in C but then again there is no array data type or vectors to store few numbers in a single column in mysql and it is not advised to use Enum or SET
View 14 Replies View RelatedI'm trying to search the string "Listen" in a few files (config files). I madefind /apps/apache* -exec grep -H Listen {} ;but the result list is very long. How i make a "grep -v" whith this command?
View 3 Replies View RelatedThere are millions of files in many directories. Wherenver i try rm * or find or use xargs, they say 'argument list too long' and exit. How can i deleted files in a directory with so many files without deleting the directory itself.
View 3 Replies View RelatedI have two files
Code:
we have to consider here $5 , $6 , $7 for our search
file2.txt
Code:
Here we should take only $2 for comparison. As you can most of the $2 field records has value and some do not have value.
Question:I want to take the fields $5 , $6 , $7 from file 1 and compare it with $2 field from file 2. and the rsult should be like this:
Code:
The final output will look like this
Actual file1.txt (before running the code)
Code:
FIle1.txt after running the above said condition
Code:
So the field $5 , $6 , $7 should get replaced from the matched valued of $1(file1)
I'm trying to make my program as small as possible. Currently it's down to 17.8 KB, but I'd like to get it smaller (I know, I'm insane). Is there a way to not use the "#include" directive to include the entire header, but rather to just load only the stuff I need? For example, I just want to include 'sprintf' and 'printf' from stdio.h, not the entire header. Is this possible? Or am I misunderstanding some fundamental element here?
View 14 Replies View RelatedI have been doing some work with assembly and low level stuff like that and had some questions. When programs are compiled they are converted into machine language. The problem is that all of the books I read assumes the user uses Linux. How come windows .exe files can not be run in Linux? I under stand there are some proprietary software that might be required like directx but I'm not talking about that. How come the same C program compiled in a Linux environment and a windows environment cant be interchanged? What is physically different about compiling a program in windows and Linux? Is one way better then the other or are they just different ways to reach the same place? I haven't done any work with apple computers but I assume that its similar to Linux.
I have been looking around the internet and the best answer I have been able to get so far is "because that's how it is" and "because windows uses file extensions". If somebody were able to give me the facts or point me to a website that does I would be very happy.
i have some files name libbeet.so.3.02 , libpos.so.3.04.I think all is binary files , but i am not able to see the contain of file.is there any script to read the file contain.
View 5 Replies View RelatedI am trying to copy content of single folder to multiple destination simultaneously using tar and FIFO. here is the source code
mkfifo bin1.fifo
tar -C bin -cf - . | tee bin1.fifo | tar -C bin2 -xf - &
tar -C bin1 -xf bin1.fifo
[code]....
I have several classes that I use for multiple programs. Where should I keep the h/cpp files so I only have to add the #include for the compiler to find them?
View 9 Replies View RelatedI use a mencoder line to convert .avi to .mpg (dvd player compatible), it works well but i can only do one file at the time. It requires giving the input and output directories and the files name. I tried using (*.avi *.mpg in the command) on the directory but it just add up all the .avi and convert them into one huge .mpg. My goal is to have a script that would convert all the .avi files from a directory to the same amount of .mpg and also keep the naming of those files. Here is what i work with on single files:
Code:
mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd -vf scale=720:480,harddup
-srate 48000 -af lavcresample=48000
-lavcopts
[code]....
have a file (called it A) contains;
hostname 192.168.23.65
hostname 10.18.13.253
hostname 10.18.16.253
hostname 177.23.56.58
how can i write a script to get only ip addresses & send it to 3 files with the following info. only:
file1:
192.168.0.0
file2:
10.18.0.0
file3:
177.23.0.0
by creating the 3 files then i will be able to set up subnetmask, gw,....etc.
I'm completely new to scripting and I'm trying to figure out how to write a script that will get a list of all the files in a directorywn through any subdirectories.When I have the list I want to o each file in VI and change the fileformat. So far all I have been able to figure out is that VI can do the batch processing and that "ls -R" gets me the recursive file list. I'm still pretty clueless on how to do the batch process with the VI editor. I think I'm supposed to use the Ex mode but I don't know how to get the list of arguments from the filelist into the editor so they can be processed. If it matters the files were all written in a Windows editor and have gotten the MS carriage returns so I want to do a :set ff=unix command on all the files without having to go into each file manually, there are over 300 files that need updated.
View 3 Replies View RelatedI have 100 sets of EPS files. Each set contains 3 files. I was wondering if it possible to arrange each set in such a way that 3 EPS files will be on one page?
I know how to write a bash script with "for" or "do" loop. how to arrange the EPS files, which are produced by gnuplot.
I am fairly new to linux but I want to write a function to find any file with only a partial name. I can only use sh shell and busybox applets for this.I could do something like the sad code below...
Code:
TEST_ONE=$(find /path/to/directory -name *$1*)
TEST_TWO=$(find /path/to/directory -name $1*)
TEST_THREE=$(find /path/to/directory -name *$1)
[code]....
fi I just made that up but obviously it is pretty bad I'm sure there is a much better way to do it but I just can't think of a way. I also would like to have the file found even if capital letters are used and the file is all lower case.
I've been wanting to try editing programs on linux (like for my own personal mods), but I cannot find out how to load the source files into an IDE, I don't want to use Kate or gedit because it's time consuming looking at 50+ files trying to find where a piece of code would be at (say trying to find ColorDrawer.Tablet.MakeFile(thisfile,here);, and having to look for a file with the ColorDrawer class) back when I was on windows I used Visual Studio, and I liked how I could highlight the classes or actions and open the file that they were within. I've tried constant programs, MonoDevelop, QT Creator, CodeBlocks, etc, but I'm clueless as to how to actually get a source code to load into a solution. How would I go about getting say http://neverball.org/neverball-1.5.4.tar.gz into a solution for MonoDevelop (or any other IDE)?
View 9 Replies View RelatedI have spent the last hour searching for a solution to this, but I can't get it to work. Here is what I am trying to do:
I have directories for different months in one folder. So for example Code: ../folder/Jan/
../folder/Aug/
etc. Some of the folders have a dot in front of the month as so: Code: ../folder/.Sep/
../folder/.Oct/
[Code].....
I am trying to find all the csv files EXCEPT those in a folder that has a dot. For example I want all the csv files in ../folder/Jan/ but I want none in ../folder/.Oct/.
I also want to exclude all the files in the /Aug/ folder that represent days 10-31.
Here is what I have so far: Code: find /some_path/folder/ ( ! -name "Aug[10-31]*.csv" ! -path "/.*/" -name "*.csv" ) | more This command lists all the .csv files except those in the /Aug/ files. So it just ignores the /Aug/ folder completely but lists every other .csv file.
I feel kind of embarrassed posting here, but this is technically a scripting sub-forum. Here is the problem. I have a folder with various files which include .txt files as well
How can i redirect same content to each of the .txt files in the folder?
I have tried
Code: $ echo "hello" > *.txt
-bash: !": event not found Code: also cat ~/otherdir/test.txt > *.txt
-bash: *.txt: ambiguous redirect Can anyone help me with this?Ok i solved it
Code: #! /bin/bash
for file in *.txt
do
echo "Text that needs to be written" > $file
done
I want to count the number of files in each sub folder of a directory structure. At the moment I can do:
ls -1R /Folder | wc -l
Which lists the item count for all the folders as one. I can do:
ls -1R /Folder wc l
Which lists all the folders in the top level and all the items. Is there any way to get the list of folders and then item count for each folder?
I need to convert some .flac files into .mp3.
I found this script:
#!/bin/bash
FLAC=$1
MP3="${FLAC%.flac}.mp3"
[ -r "$FLAC" ] || { echo can not read file "$FLAC" >&1 ; exit 1 ; } ;
metaflac --export-tags-to=- "$FLAC" | sed 's/=(.*)/="1"/' >tmp.tmp
[Code].....
And I need it to run it from outside of a directory for several directories.
I need to run it from /dir for /dir/dire*
This is probably a really stupid thing to ask considering the development I'm doing (effectivly creating a virus scanner), but how do I link classes/cpp files?I have 3 applications/sections that I can compile/combine with a makefile, that's fine, but I need them to run 1, 2, 3 once the output from the makefile is done.Currently the only section to actually run is whichever I have "main" in and obviously if I put that into all three, they won't compile as one.I've been looking all over the place at all sorts, header files and such, but there is no mention of how toually do this although I'm sure it must be possible. I'm used to being able to do this in Java and I'm sure I've seen C++ applications do it, but not worked out how.I have 3x .cpp files which are combined into one using a makefile:
Code:
# Virus Scanner
scanner.out : ProgramList.o MD5Hash.o HazardCheck.o
[code]...
I'm trying to change a line of a bunch of xml files (more than 800).What I want isto change this line:
Code:
<variable name="reliability" size="1">96</variable>
to
[code]...
I have two text files i want to compare the differances between but i dont wnat all of them, there is only about 30lines of relvent text i want to compare.
View 10 Replies View RelatedI would like to ask opinion from perl experts.
I want to compare 2 files and show the differences in a text file.
For example, if i open File A an B in notepad
File A:
File B:
Quote:
line3 is missing in File B
So if I did a File compare (line by line), the differences will be in line3, line4, line5, line 6.
But I dont want it to be like that.
I want it to be like this
Quote:
Can Text:: Diff able to perform the work.
My backup script generates 2 lengthy log file. They have the same name, but the date is appended. I want to select the oldest one, condense it with "head" and "tail" and then append the condensed version of the newer one. They seem to get tangled up.Code:
ls `find . -iname "bak-log_*"` -1t | tail -1
and
ls `find . -iname "bak-log_*"` -rt | tail -1
[code]...