I've written a for loop with a counter i and I want to use the value of i within sed to edit certain lines of text within a fortran file.I want the the x=10 will be replaced by x =1(counter from the loop).. and so on.But from the following code my x = 10 is replacing by x = i.So
#!/bin/bash ls -lhGg | while read line; do echo "$line"; done | awk ' { print $3" "$6 } '
what i want to do is be able to print column 3 and every column greater then 5. Has to be to the end of the line, since different filenames can have different amounts of words in them and the blank space is the separator. my current code works just fine if the file has no blank space.
I have a text field that is just list of servers and I need to add the word hostname in front of them... It must be brain fart but I can't think of how to do this. Basically I need this:
I would like to make a file with all these data in one column, like
a1 a2 . .
[code]....
Can it be done with awk or some other command? Also, is it possible then do add another column in front of this one with numbers of the lines (for every previous column), like
All I want is a command that reads one data file with several columns and prints it in another one.However, whenever the value in one specific column alters, it prints one empty line in the new file. For example, consider the file
I am trying to import a data file from old DOS application into MYSQL table The file is clear text file with fixed-width columns, without column delimiters
Example file : Code: 4444333666666 2222666555555 iiiiwwwcccccc
I am splitting a file based on the values read from an input file. The below one is the script.
1)How do I add the header which is present in the original file to the new split files created?(For eg. pharmacyf conatins header as table column names. The new files created (ODS.POS.$pharmacyid.$tablename.$CURRENT_DATE.dat) are without the header).
2) Also the script is creating 0 byte files for the pharmacyids which are not available in the intial file? Can this be avoided?
for pharmacyf in * do tablename=`echo $pharmacyf |cut -f4 -d'.' ` while read pharmacyid do grep -w $pharmacyid $pharmacyf >> $OUT/ODS.POS.$pharmacyid.$tablename.$CURRENT_DATE.dat done< inputfile done
Alright, so I have been trying to resolve this issue for awhile, but now feel like help is very necessary.I have a 128(by)128(by)128 array in a MAT file, and am using the following MATLAB script to convert it to a DAT file:
I want to read content of a file inside a gawk script.I know that by using "gawk -f filename" I can read a file, but I want to do that inside the script.
I am trying to read the contents of a file into something else. I have a file.txt that I am working with, I want to read the file and take the data and run some commands with the data that it read. So if it read www.yahoo.com I want to be able to nslookup. Does that make sense? I have been trying to use the read command but that does not seem to work. I even was trying to read filename | > filename to see if I could even read any of the data at all. Nothing is working.
have been playing around with a script for a few hours and now I need to be able to output the lines in a text file one by one to be used later in the script.What it gonna do is to read a log file and grep the usernames, then write them to a file, and then run one script for each user, to search for more information about them in the log.But I don't know how to output a single line from a file, and google does not return any solution.
I am trying to read from a file named matrixA.dat that contains a matrix formatted like this:
2 x 3 1 0 2 -1 3 1
I am reading the lines in, and this is the source that I have so far: Code: #include <stdio.h> #include <string.h> #define DATALIMIT 17 #define DIMLIMIT 5 #define NAMELIMIT 40
[Code]...
was stored in dataA, so when I print it all I get is a newline. Why didn't it grab the 1 0 2 -1 3 1 line?
I have a script that reads part of a line, delimited between the first and second intended part by a colon. Then it "chops" the part after the colon, which are words offset by commas (counting them beforehand so as to catch every word in the string's second part), like this:
Code:
"COLORS.JPG:red,orange,yellow,green," (Returning) red
[code]....
single script that parses/breaks both parts of a line like this "COLORS.JPG:red,orange,yellow,green;blue,indigo,violet," so that the two parts, separated into single words (or two and three words, sometimes with spaces) can be used as single-line annotations and written to JPEG files using Exiv2. So far, I haven't been able to come up with a script that does this without one part of the total string(usually that part after the colon) becoming the first word in the second array. In other words, I look for this:
KEYWORDS:
[ ]red [ ]orange [ ]yellow
[code]....
Or vice-versa (ie, the second array winds up as a single-line "member" of the first). I think it's because I'm using a single while read loop to read the text file in which the filenames and substrings happen to be. If there's some way of reading a file once and going back to the beginning to read it again in another while loop, I haven't found it.
I am struggling with Bash scripting at the moment (I can't seem how anyone can write scripts with this language!!!) I have a need at home to have a cron job execute daily to lookup my downloads.txt file, read each url (per line) and download content from that url. Then that entry needs to be removed (well I keep all urls in memory and clear the file afterwards). If an error occurred during the download process, then the url is written to a downloads.err file. I got all the above working except for properly reading the url from the text file without including newline characters. I am using the following to read:
while read url; do --Do whatever here-- done < downloads.txt
How can I get it not to let the url variable have newline characters?
i am trying to read in a file 1 line at a time and for some reason it stops printing out at about line 62,000.
i am doing this: Code: while(fgets(c0, 1085, fstream0) != NULL)
but after about 62,0000 lines it stops printing. no seg-fault, no core dump. it just stops printing to the terminal then returns me to the command line after a couple of minutes. as a hack i am doing split -l 50000 on the input and calling my program 5 times.is there some limitation on fgets that i am not understanding ?
a project using bluetooth to send data byte by byte to external devices buti'm not familiar using arrays to read file from another location before sending the data.If you could,do correct my codes.Here's my code,
i have wrote a long piece of code above with the "main" which is calling openFile( &fout, filename )filename contains the txt name in a form of "data.txt"i wanna read the data from the file and output it into fout for later use.the data in that file is a vector looking interger group.i have the following code:
I'm writing a program which now accepts user input:
Code: echo "Enter a date in the format YYYY MM DD hh mm ss."
read gregyr gregmo gregdy greghr gregmn gregsc This lets the user input a date and time, such as 2011 06 21 15 12 45, and have each number assigned to their corresponding variable. Later in the program, these variables are put into an equation, and then the terminal spits out the answer. Now I have to have the program read all of the lines from a text file, which is in this format, assign the variables.
I am writing a script that involves reading the content of a file present in a directory and/or its sub directory. I know readdir returns all the files & DIR names in a directory but how to check weather readdir is returning a file or a directory
What are the possible problem when Windows access the file from Ubuntu got Read Only even though have a full permission to read, write and execute the file? Ubuntu to Ubuntu accessing the file there is no problem only Windows got a problem.
I ran into it while google Segmentation Fault. I'm writing a simple C program that reads a file that counts each line and numbers it then writes to a file called sdout. I copyed my program mostly from the text book but im still having problems. Heres my code:
instead of importing a file I would like to use the variable $x I tried using pipes, but with no luck. My goal is to read one line at a time, but not have to export my data to another file, I would like to keep it all within one script.
I am trying to make a perl script which reads data from a file and parse it. The data in the file has the following syntax
Code: Device Physical Name : Not Visible Device Symmetrix Name : 1234 Device Serial ID : N/A Attached BCV Device : N/A Device Capacity
[Code]...
Each unique record starts with "Device Physical Name". So, I have a set of records within "Device Physical Name". I want to read this set of records starting from "Device Physical Name" and ends up till next "Device Physical Name". Offcourse FS is ":", and I just want to print/or later put info in a csv file.
How can read the file /var/etc/allInOne.cfg and distribute its contents on multiple cfg files using C language. /var/etc/allInOne.cfg contain the data and the path of each text file.
The source file "/var/etc/allInOne.cfg "look like this: line1 line2 ... line10 filePath:/var/etc/file1.cfg line12 line13 ... line14 filePath:/var/etc/file2.cfg linen .. filePath:/var/etc/filen.cfg the result will be :
The expected result is: /var/etc/file1.cfg will contain line1 to line10 /var/etc/file2.cfg will contain line 12 to line13 /var/etc/filen.cfg will contain linen to linen-1