Programming :: Redirect To Multiple Files?

Nov 12, 2010

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
echo "Text that needs to be written" > $file

View 2 Replies


Programming :: Redirect The Output To Multiple Files Without Displaying It To The Screen?

Oct 26, 2010

To redirect standard output to multiple files:


echo Test | tee file1 file2

My problem is that the word "Test" still displays to the screen? I want same effect as:


echo Test > file1

but with multiple file redirection.

View 3 Replies View Related

Ubuntu :: Redirect Curl Output To Multiple Files?

Nov 6, 2010

I am using curl as the following

curl "{1,2,3,4,5}.html" > /home/myuser/allpages.html
i need to save each page in a separate page by the way i have tried this command
curl "{1,2,3,4,5}.html" > /home/myuser/{1,2,3,4,5}.html
but it displays error
ambiguous redirect
is there any way to do that

View 5 Replies View Related

General :: File Output Redirection - Redirect Stream To Multiple Files?

Dec 7, 2010

I'm working on some scheduled task script files to keep nightly backups of some of our database information in place, and it's a bit annoying when they blow up. I know how to redirect stdout and stderr to a flat file I can view when I come in, and I know that 2>&1 maps them both to the same file (whatever was named in 1). However, I'm running into some cron-time situations where it's easier to have the two streams together, and other cron-time situations where it's easier to have them separated. I can't really tell which is going to happen; is there some way I could create both kinds of output file for my scripts, so that I've got a std_err only file and an interleaved std_out/std_err file?

Note: I've looked at the 'tee' command, but I don't think it will work for what I'm after. 'tee' appears to only work with stdout; I'm trying to work with stderr.

View 5 Replies View Related

Programming :: Redirect Output To Files Using Shell?

May 21, 2011

I have a huge database of students, I would like extract these data and write to individual file for each students.

I am running a loop in shell program (.sh file), the output of each run in the loop need to redirected to a file with variable name.

I tried the following line, but it did not work, where BodyMsg is the data and Rollno is the students roll number.

echo $BodyMsg > $RolNo".html"

View 5 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

Programming :: Getting A Script To Be Run On Multiple Files?

Apr 17, 2009

I 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:


mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd -vf scale=720:480,harddup
-srate 48000 -af lavcresample=48000


View 3 Replies View Related

Programming :: Grep Multiple Files ?

Dec 30, 2010

I want grep multiple files:


I use grep <pattern> abc.* to read the files. But here grep read files in the order of 1,2,3,4 . I want to to grep the files in reverse order like 1st the abc.4 file will be read and abc.1 file will be last.

Is this possible ?

View 3 Replies View Related

Programming :: Multiple Files To Compile By G++?

Jan 12, 2011

how i could compile for example: a tutorial file of cantera open source files. when i do :g++ example.cpp -o examplei get huge errors such as the header files are not here,...please tell me how i could compile it. ofcourse i have configured the full opensources and i see in /usr/local/cantera/binthat the files are there but i still can not compile and execute any cpp file.

View 2 Replies View Related

Programming :: Execute Multiple Sql Files Using Scripting?

May 19, 2010

My query is i have a.sql , b.sql , c.sql files which needs to be executed using "$ db2 -tvf a.sql"; "$ db2 -tvf b.sql"; "$db2 -tvf c.sql" , script with which i can execute all these sql files in a single shot.

View 4 Replies View Related

Programming :: Reading Data From Multiple Files?

Mar 17, 2011

I have a folder which includes bunch of folders each having data files in them. [ Folder A has F1, F2 F3 ..... F1000 folders in it, and F1, F2, F3 ... each has about 10 different files named FILE 1, FILE2, FILE3 .... in them.

I am interested in File 1 of each Folder, because that contains the data I need in it. More specifically, that File1 s have a line "ANSWER=..." in them, and i need to get that value of the ANSWER from each file. So doing it by hand is so hard, so I need to write a script that will scan all folders and give me a list of values of eache ANSWERs.

View 4 Replies View Related

Programming :: Quickest Way To Do Multiple Searches For Files

Apr 15, 2010

I am looking for the quickest way to do multiple searches for different files.Here is the scenario: I want to search for various icons one by one in a script. Preference is for the gnome icon theme.

The echo piped into grep part seems to take a long time. Is there a quicker way of doing this?I do not want to use slocate, sqlite or the like since that will require admin privileges to update the database and/or extra dependencies.

View 5 Replies View Related

Programming :: Calling Multiple Files In FORTRAN90

Oct 29, 2010

I have written FORTRAN code to calculate density profile. This code will open two files ( topology and x,y,z trajectory). The trajectory file contains XYZ data coordinates for multiple frames (about 20 or 100 frames for instance). One frame contains 20736 data.

Previously this code was written to open ONLY one input XYZ data file and do the calculation and would dump the results in separate file and it was running without problem. Recently my data file get bigger in size, so I decided to break the single XYZ data file into few small parts.

Now I have modified the code so that it calls the parts of the XYZ data files ( eg: maltoTHERMO_10Frames.traj, maltoTHERMO_20Frames.traj,... and so on) and do the calculation and dump the results in the same result output file. I have tested this code just with openning the XYZ coordinates and printing into another file to see wheather it collecting the data sequently and it was working fine.

This code supposedly read the x coordinate data and calculate distance and put a count accoding the criteria in the approperiate bins. But when I let the code to do the calculation it stop and shows error. (I have indicated as !** in the code). If I enable this line, it shows error but if I disable this line, than the code do collect only the XYZ coordinates.

The code is as below:


module all_parameter
integer,parameter :: MAXATOM=20736!CHANGE
integer,parameter :: midwater=1500
integer,parameter :: TOTALFRAMES=20


View 8 Replies View Related

Programming :: Compiling And Linking Multiple Files Using Gcc?

Mar 13, 2011

compiling and linking using gcc: What does a file name with a suffix '.a' represent? If I have multiple .c and .h files, how can I link them together? How can I create the .a file?

View 6 Replies View Related

Programming :: Copying Multiple AVI Files To NAS Server

May 18, 2009

I am working with DM355 target board. Here we record. The video coming from IP cameras. Now I have to write c program for copying. The recorded avi files with date and time to NAS server using scp. I wrote a script to copy single file to NAS server.

DATE=$(date +%Y%m%d_%H_%M_%S)
mv Camera1.avi Camera1_$DATE.avi
scp Camera1_$DATE.avi root@
mv Camera1_$DATE.avi Camera1.av

But I have to write c program for copying multiple avi files with Date and Time to NAS server.

View 5 Replies View Related

Programming :: Replace Html In Multiple Files (80+)

Mar 2, 2010

I want to change some HTML in my files (80+ so I prefer not to do this by hand). I got a script to replace a string in files, however the HTML I want to replace contains an enter (and tab of 4 spaces) (explanation below) Does someone know how I could update my HTML by using a function in Linux?

I also found sed but don't know how to use it with the enter (linenumbers will not work because they variate)...


View 2 Replies View Related

Programming :: Shared Libs - Multiple Files In C++?

Oct 20, 2010

I'm trying to change a group of cpp files to one shared lib. I have created a shared lib with a single file. I then did this with a group of files. The difference in what I'm doing is that before with the single file, .a, was added into a single .o file. Now I'm trying to add it to my main.cpp file which is NOT a .o file. I'm now getting these compiler errors from the main.cpp where is doesn't seem to recognize the semaphores.Example Error: undefined reference to `sem_wait'If I were not to use the share libs this compiles and runs as I expected it to.Something tells me this is a compiler flag issue, at least I hope it is

View 1 Replies View Related

Ubuntu Servers :: 301 Redirect Or ServerAlias For Multiple Tld's?

Jun 19, 2011

Our company owns multiple tld's for our corporate domain (e.g.,, etc.). Currently, we operate the main website at [URL]. To have "" et al forward/redirect to "", should we use a 301 redirect or setup a ServerAlias in Apache's virtual host directive (we use name-based virtual hosting on Ubuntu Server). Are there any SEO penalties from one approach vs. the other (e.g. Google thinking you have multiple sites with the same contact + flagging it as spam)?

View 2 Replies View Related

Programming :: G++ Fails On Multiple Files If There's A Template Involved

Aug 12, 2010

If I remove all the template stuff, it works.

whats going on here?

View 2 Replies View Related

Programming :: AWK (or TCL/TK): Matching Rows And Columns Between Multiple Files?

May 26, 2011

I've been hitting my head against a wall for awhile with this one:As the last part of some data analysis I performing I would to construct a matrix from a series of different files. These files have the format:

file 1 file 2 file 3


View 6 Replies View Related

Programming :: Bash Scripting - Output As Multiple Files?

Jan 26, 2011

I have wrote a 1 line command that parses a file, locates the IP Address in the file and then trims the output the way I want it, and then sorts numerically and by uniqueness and then >> appends to output.txt

I can get all the IP's into 1 file "output.txt", but what I am really looking for is some type of way to create a text file, for each IP it finds labeled and also put that ip address into that file.. = the ip address it finds

View 14 Replies View Related

Programming :: Copy Lines From Multiple Files To One File Using Sed -w?

Aug 25, 2010

I've been trying to sort this out for several hours and I?m totally lost? I?ve been searching around, but haven?t found the solution to my problem. I have a directory with 100 files. I need to copy 10 lines of each files (let?s say from line 45 to 55) into one unique file. So I guess I could use sed ?w, but I didn?t manage to write the right script. I also tried using a loop to create 100 different files, each one with the 10 lines) to concatenate them later on. But I only got 1 file, not 100.

View 12 Replies View Related

Programming :: Bash Script To Rename Multiple Files?

May 9, 2011

bash script to give sensible names to a large number of photos. I hope to be able to run a script with an argument which will become the filename followed by a number beginning at 1.

./ Summer2009_


View 1 Replies View Related

Programming :: Script To Pass Multiple Files To Program?

Feb 8, 2011

I'm playing around with a bash script to pass files to a program (such as VLC). I thought something like this would work:

vlc $( ls | sed 's/ /\ /g' | tr '
' ' ' )

ls shows the files in the current directory, then sed changes spaces to " " (to escape them) and finally tr removes the line breaks. I end up changing:

01 - Music Track.mp3
02 - Another Track.mp3

01 - Music Track.mp3 02 - Another Track.mp3

"vlc 01 - Music Track.mp3 02 - Another Track.mp3" works if I type it manually but my script reports a problem with `-'

It seems it's not escaping the spaces.

View 4 Replies View Related

Programming :: Bash - Rename Multiple Files With Dots In Filename

Oct 3, 2009

i have lots of files with dots insde file name for example:

i want to rename all files in that directory to be the same (with same extention) but convert dots to underscore "_"

how can i do that on bash script / php.

View 6 Replies View Related

Programming :: BASH - Renaming Multiple Files In Foreign Language?

Mar 6, 2011

I have this cool bash script that I worked hard on. But it broke down when it can across files that had non-English characters. Another small problem was getting it to descend into a directory. If it renamed a directory it would not descend into that dir to rename the other files. I would have to run the script twice on the same directory.

Here is the script:
find -type d -o -regextype egrep -iregex '(.*.ogg|.*.mp3|.*.wav)' | while read s
rename -v 'y/A-Z/a-z/' "$s"
find -type d -o -regextype egrep -iregex '(.*.ogg|.*.mp3|.*.wav)' | while read n
rename -v 's/ /_/g' "$n"
A French name like this:

Chateau De Sable (imagine accents above the letter a)
became this:

This is not what I wanted.

Why would the script not descend into a directory after it was renamed?

View 7 Replies View Related

Programming :: C++: Compiling Multiple Source Files (with Templates Involved)?

Mar 21, 2011


anisha@linux-uitj:~/junk> ls -R
include src
template0.h template0.h~ template0.h.gch


View 11 Replies View Related

Programming :: Linking And Compiling Multiple C++ Files Into One Executable Program?

Dec 17, 2009

I have 3 c++ files, classdef.h (header file with class definition), methods.cpp (class methods) and program.cpp - the program itself. Both .cpp files have


#include "classdef.h"

in files. How I can link the files together and compile them in one executable program? I am using Geany IDE for coding.

View 4 Replies View Related

Programming :: Split Multi Line Record Into Multiple Files With Awk?

Nov 11, 2009

I have a large file 'NS0923.csv' with data like the following. There are two records in this multi-record sample.


E60898,4578910,03/06/09,BEN BOYD RD,61,82,,,127,3,,52000.3046.001,3155,4.00,,PLT,1356,1.00,05/06/09,Y,Y,0551
,,,,,,,,,,,,4057,1.00,CLEAN CAR SHARE SIGN,LAB,0551,1.00,,,,


2. I still have to create a file 'transaction.csv' that should retrieve data from $13 - $15 with the identifying column $1. Required output:


E60898,4057,1.00,CLEAN CAR SHARE SIGN

3. And finally another file 'quantity.csv'. Retrieving data from $16 - $18 with identifier $1. Required output:




View 10 Replies View Related

General :: Redirect Stdout/stderr Of Multiple Commands In One Shot?

Jun 3, 2011

I have several commands in a bash script, and in the middle of the script there are several commands whose output and error streams I want to redirect to a file. I think I could simply add '>> myfile.txt' to the end of every command, but is there a way to set it before that block of commands, then reset the streams to their original state at the end of that block?

View 1 Replies View Related

Copyrights 2005-15, All rights reserved