Fedora :: Write A Bash Script That Will Create A New Text File?
Oct 22, 2009
trying to learn how to write a bash script that will create a new text file named jimbola in my home directory. The file will need to be able to have the first and last name of Jim Bola included in it.
View 4 Replies
ADVERTISEMENT
Feb 15, 2011
At the moment I got my md5sum checking working which I write to a text file and see below.
If the md5sum works it will write the output to check2.md5 test.txt: OK
If the md5sum fails it will write test.txt: FAILED
How do I write if statement to check the output whether or not the md5sum failed or not ?
check1="/home/ops/Desktop/test1/check1.md5"
check2="/home/ops/Desktop/test1/check2.md5"
cd /home/ops/Desktop/test1
md5sum test.txt > $check1
[Code]....
View 2 Replies
View Related
Apr 27, 2011
I want to write a bash script to parse a text file with the following lines and set variables for each line so that I can use them in the rest of the script.
Timestamp=123456789
Company=ABC Company
Server=Server
Recipient=Joe Smith
Email=joe@abc.com
simplest way to read each line one at a time for everything before the =, set that to a variable name with the value equal to everything after the =
View 14 Replies
View Related
Jun 10, 2011
I have a text file that contains a single word and I want to write a bash script that will read the word from the text file... The following is my incorrect attempt, as it assigns the name of the textfile to the variable as opposed to the word stored within the textfile:(assume I have a text file value.txt that has its contents a single word, say wordone)
Code:
#!/bin/sh
for f in value.txt
do
echo $f
done
so the output of the above script is value.txt, however I want it to be wordone.to summarise: how do I assign the value of the word contained within a textfile to a variable?
View 1 Replies
View Related
Mar 8, 2011
Firstly i'd like to introduce myself before I ask my question, i am currently studying a "Network Operating System 2" course, and in the syllabus the professor decided to use Ubuntu Linux for us. This is a first for me and I am truly greatly interested in the OS. It seems like a solid system once you get to know the deep foundations of it. The professor has already given us an assignment, but I feel its not fair as its just a bit too much from out of what he taught us .. He did not teach us what he is asking for. He asked us to create to a text file which lists the Sales from two Salespersons, and each one will have an amount for each month .. So 12 entries for each salesperson.
Using that text file, we should write a bash script which would read the values from the above text file, and produce a "Monthly Sales" text file, which shows the total sales of each month (combined from both the salespersons). I would like to ask for some guidance, some help on how to start. It's just that he didn't teach us any commands about this matter.
View 9 Replies
View Related
Jul 3, 2011
I have a huge issue on this error on mysql. Can't create/write to file '/tmp/#sql the full error message is Can't create/write to file '/tmp/#sql_4761_0.MYI' (Errcode: 30)
View 9 Replies
View Related
Nov 29, 2010
I create a bash script that writes another bash file. But in the generated bash file I want to write a bash command in the file and not executing it.Here's my bash file:
Code:
#!/bin/bash
cat > ~/generateGridmix2data.sh << END
[code]...
View 6 Replies
View Related
Oct 17, 2010
I have started using Ubuntu and I have to add a large number of users, over
a thousand, using a Bash Script. I also have to give them a password. Do you create a text file first.
View 1 Replies
View Related
Oct 10, 2009
I need to do some text file manipulation which I think should be done with standard commands in BASH. I'm looking at comma seperated text files (stock market data). It comes in the form of date, stock code, open, high, low, close, volume. What I need to do first is move all data with same stock code sequentially into individual files.
While doing this since the stock code will now be the file name I need to remove the stock code. Next I need to filter out overlapping data from different files with the same date. ie. where two files contain the same date on the one line only one line will be added to the combined file. I think there must be a tutorial out there for basic text manipulation like this, I just haven't found it yet.
View 11 Replies
View Related
Oct 6, 2010
how come I can create a shell script file with two functions, I can execute the file, but when running declare -f, the functions are not on memory, and when invoking the function bash returns invalid. In the other hand, I can copy & paste the two functions at the end of my /etc/bashrc file.... then I can called the function by name.... and the commands within that function run on my session. here is a print of all my bash packets:
[Code]....
Does Fedora has restrictions on shell scripting? I haven't touch bash in seven years, so if things have change on it I'm behind on it, and sorry for my ignorance.
View 1 Replies
View Related
Apr 7, 2010
i am trying to write a program which will read input from a text file, check if each line contains any alphabets and then display a message imforming me if there is an alphabet in each line. My text file is formatted in this way...
[Code]....
View 2 Replies
View Related
Aug 5, 2011
I mean codes on how to write a bash script for locate file. E.g: This utility shows you all files and directories that have a specific substring in the name. Press '?' for help, 'q' for quit or enter your search terms:
Kuala bin
I have searched for two terms for you,
Kuala, which has three hits:
/usr/share/zoneinfo/Asia/Kuala_Lumpur
/usr/share/zoneinfo/posix/Asia/Kuala_Lumpur
/usr/share/zoneinfo/right/Asia/Kuala_Lumpur bin, which has 2312 hits.
Are you sure you want to see all of those? [Y/n] n
Press '?' for help, 'q' for quit or enter your search terms:
Sorry, you didn't enter any search term.
Press '?' for help, 'q' for quit or enter your search terms: q
View 8 Replies
View Related
Feb 7, 2011
I want to write expdp output in a text file using a shell script
If i write like below:
It will write whatever is there in log file to text file
But, sometimes export fails with out start taking export (without generating log file) because of job already exists error. such times, we dont know about that error until we check manually... so i wrote like below:
But still it is not writing anything in to text file using above stmt...
View 1 Replies
View Related
Aug 3, 2010
i need to write a c code to ping IP addresses which are read from a text file and need to log the response time in another text file.
View 4 Replies
View Related
Sep 10, 2009
Actually i m new to scripting in Linux, we have RedHat Server Edition 4 in which different software licences are installed and software itself installed at client side. the usage of the software is recorded daily in a text file which is of format
I want to write a script that checks that for any OUT & IN, if utility, user and Client PC Name are same then subtract OUT Time from IN Time. This has to be done for each & every user and utility.Is there any GUI programming possible in Linux.
View 7 Replies
View Related
Nov 11, 2010
What I plan to do is, create a duplicate file of a text file, and then append some text into the new text file.
View 1 Replies
View Related
Jan 20, 2011
I have a bash script that checks for contents in a folder every 15 seconds and then acts on it's contents. This works great for the average size file however on very large files it starts acting on the file before it's completely written. Is there a facility in bash shell to get a file complete signal or such? here is trigger to launch a larger script.
Code:
#!/bin/sh
while true
do
$HOME/bin/hpgl.sh >/dev/null 2>&1 &
[code].....
View 10 Replies
View Related
Jan 31, 2011
I have a folder of 2 many files that the old ls just hangs.
I am trying to write some log files such as;
I don't mind doing one at a time, but I am just playing and even getting the listing I am not getting the date stamp, I have the following;
That does create the file, but all the files look like this;
So basically it's just sticking that ls inside the log file and not actually running the ls, so how can I use the above type to get files just created per year?
View 2 Replies
View Related
Nov 8, 2010
I need to Read a path of a file witch is written in Text file i used this
Code:
FILENAME=$1
while read line
do
echo $line
done < $FILENAME
it worked and showed me the Line witch was written in my file but now my problem is how am gonna use that line as a path i mean for example if am gonna execute a linux command on that file like dpkg -i /path/to/the/file how am gonna export it from The $Line variable and use it after the command.
View 14 Replies
View Related
Jul 16, 2010
Something very handy to do in a Linux shell, is manipulating files and strings - essentially parsing data. Write a utility which will scan in a text file and search and replace strings. We also want to keep track of how many strings we've replaced.
I know that my command would look like this: <utility name> <filename> <stringToSearchFor> <stringToReplaceWith>
Code: #!/bin/bash
[code]....
View 2 Replies
View Related
Aug 5, 2010
trying read serial COM port and want to write that received data to file, now its writing only one sentence, but i want to write full file which coming on serial port, as i'm sending file from hyper terminal and reading on linux pc, If i put while loop its not writing anything,without while loop its writing only one line and if send big file then application terminates and then writes to file.But i need do write any size which coming on serial port.Finally i want write full file which is coming on hyper terminal, after writing the file it has wait for next data. This is my code,
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
[code]...
View 9 Replies
View Related
Jun 16, 2011
I have a file like:
a
1
2
[code].....
and I would like to convert it to CSV, so that it looks like:
a,1,2
b,1,2
c0,1,2
d0a1,1,2
Basically, I would like to move every 2nd and 3rd line onto the above line, and put a comma to separate
View 5 Replies
View Related
Jul 12, 2010
I am tying to write a script that asks for user input and saves it to a text file using awk so example #!/bin/bash read a awk #saves to file
I had a working scripted last night, deleted it by mistake and for the life of me can not remember how i did it.
View 2 Replies
View Related
Mar 21, 2011
I created text for a bunch of "#!/bin/bash" scripts in MS SQL Server. Being on a Windows machine, I used Ultraedit to create text files for a few examples. After copying the files to a machine running Ubuntu 10.10, I changed group and owner, and made them executable. However, they won't execute. I get "file not found" errors. But, if I paste the content into text files created in Ubuntu, it runs fine.
View 1 Replies
View Related
Sep 18, 2010
I have a file (called twitterstatus.tmp) that looks like this:
Code:
<status>
<id>24854489768</id>
<text>Are we gonna ride the sun home?</text>
<id>55266987</id>
[code].....
How could I feed this into an array, with each element containing everything between the <status> </status> tags?
View 9 Replies
View Related
Apr 30, 2010
I have a text file which stores the list of files & dir, I want to get only file's extensions from this file & want to store it in another file.eg, below is the file's contents & from it I want to get the extensions sh, pl & h & want to store it in another file. Also I don't want directory list.
A scripts/services_restarter.sh
A scripts/svn post_commit scripts
A scripts/tmp/
[code]...
View 8 Replies
View Related
Jun 4, 2010
I had set up a Samba server on SuSE linux a few years ago with a single shared directory. It has been running fine ever since, surviving various system upgrades and hardware migrations without ever needing to change the configuration (well, maybe once or twice). However, since a few weeks ago, it refuses write access to the share. It just returns NT_STATUS_ACCESS_DENIED when I try to create or write to a file. That's also what /var/log/samba/log.smbd says (nothing more AFAICT). It's the same for all clients, i.e. remote Win XP PCs or local smbclient.
The funny thing is that it allows write access immediately after rebooting the server, but after a while (the next day or so) it refuses again. Restarting smbd or nmbd doesn't change anything here. I suspect that this started after installing the latest security updates for OpenSuSE 11.2 on May 17th. The new packages were (according to /var/log/zypper.log):
xorg-x11-libXext-2379.noarch
libmysqlclient-devel-2315.noarch
openSUSE-build-key-2398.noarch
libpython2_6-1_0-2213.noarch
libpng-devel-2159.noarch
Somehow I can't see which of these might have an influence on samba. But I am absolutely and positively sure that I didn't change anything else. I logged into the server only once in months, and all I did was doing the updates using the updater applet.
View 3 Replies
View Related
Apr 13, 2010
I can do multiscan documents using xsane and the scanner and create multipage PDF. My next wonderment was how would you create it so you can search for text in the PDF file. I am assuming the scanner is really just creating an image file. And the reader needs text? I did find a decent OCR web based solution. It looks like it would be a lot of work to put something like that together.
View 4 Replies
View Related
Jun 23, 2010
1. I need guide on how to create a folder name from the text file with .txt format.
2. First, I call the function of reading the directory.
3. Then, I dont know how to do.
4. Finally, I close the directory
This is my source code in perl
## read text.txt file ##
open F, "from/$directory/text.txt";
read F, $buf, 9999;
close F;[/size]
This source code is used to print the folder with date format like "ddmm" d stands for day and m stands for month
if ($command =~ s/-O "(.*)"/-O "$websites/$month/$file"/)
Instead, I want to have the name from text.txt to be folder name
View 4 Replies
View Related
Dec 21, 2010
I have a file with 5000 lines. it is a list of books authors, series and titles. all lines start with the author names, than there is a dash (-) than the series name, a dash again and the title of the book.
The problem I encounter is that sometime there is a series, sometime not, and as I try to enter this list in a database, I wanted to create a cvs file to import into mysql.
ex:
The best would be to be able to add in the second line, a "space dash space" just after the author name, but how to make sure it does not do it to the first line as well.
If I could separate all line with 2 dash, (grep ?) then I would be able to do a simple replace, and change the single dash into two.
View 2 Replies
View Related