Software :: Save Output Of Bash File?
Jul 11, 2011
I've shell bash file script and I want to save the output into a txt file.I Know ./bash.sh > output.txt will save the result into a file but i want to add something into a bash file and then when the bash file process completed, it save the result into a file and I don't want that overwrite the output into the old file, I want each time i run it, it save the result into a new file.
View 6 Replies
ADVERTISEMENT
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
Mar 15, 2011
I sometimes stick my neck out and provide somewhat detailed, and often risky, "Mr-fix-it" remedies for boot problems. Now, I know it's possible to amend each command with "whatever_command > whatever.txt" in which case it'll place the command output in a file in /home.
But if you're directing someone to run a lot of commands as I did here is it possible to save the output of all commands to a .txt file without amending each command?
Or is it already saved somewhere that I'm not yet aware of? I wouldn't be surprised if the latter were true, I just haven't yet found it
View 4 Replies
View Related
Mar 10, 2011
I have a bash script that i created for a colleague to configure the servers he installs. It does package installations, modifies some config files, creates directories.
The problem is sometimes he says that the script skips some steps. There are some steps that require user input and i think he chooses wrong option. (i have tested the script and it works fine).
My question is how can i save the output in a file (or log) so i can check if there are error? I know about the ">>" operators but will this "script.sh >> output.txt" still bring the dialogs for user input (like read input from shell and mysql password dialog from install package)? And how can i record everything he inputs?
I read about logger, but since there are a lot of commands do i have to log every command or can i just log the whole script.
View 3 Replies
View Related
Jul 1, 2010
I am using:
user@unknown:~$ sudo command -option > log
to save the results of "command" to the file "log", but I'd like to also get the result on the terminal, is this possible?
I am using ubuntu 10.04 lts.
View 3 Replies
View Related
Jul 25, 2010
For example, I run a program called "luck" and it outputs a sentence like "good luck". Then "./luck -> logfile" will save the output content to logfile.But when I run another program called "hello" and it outputs a sentence lie " Hello world".Then "./hello-> logfile" will save the output content to logfile and wipe the previous contents.Is is possible to keep both sentences in the logfile? Just like
View 2 Replies
View Related
Feb 11, 2010
I have got a script with an outer and inner loop. The inner loop issues loads of echo's which need to be redirected to a log file determined by the outer loop. The obvious solution is to redirect every echo to >$LOG and set LOG in the outer loop.
Code:
for f in $FILES ; do
LOG=<logfile>
for l in $LINES ; do
[code]....
it is possible to map stdout to $LOG in the outer loop without having to redirect every subsequent individual command output?
View 4 Replies
View Related
Oct 26, 2010
I know how to redirect the output of a terminal to a file. For example, if I want to list all the files in ~/Documents and output to a file called test.txt, I would do this: ls ~/Documents > test.txt The question is, can I copy the output to test.txt AFTER I have carried out the command? This would mean that I wouldn't have to know in advance whether I want to copy the output to file. I want to do something like this: ls ~/Documents Then this: <bash command for copying standard output to test.txt>
View 2 Replies
View Related
Sep 5, 2010
i'm building a dictionary with a bash script. it works perfect except i'd prefer something faster. btw i'm just piping the output to a file.
[Code]...
View 1 Replies
View Related
Oct 31, 2010
I am working on a script that allows me to convert an IP address to a country name. I have 2 files. One that has text like: PORT.80 TCP SRC=x.x.x.x and the other is x.x.x.x United States. How can I combine these files so that the file output is PORT.80 TCP SRC=x.x.x.x United States?
View 5 Replies
View Related
Jan 7, 2010
I started a command, it needs very much time. and i have to save the (error-)output. but i forgot it.
is there a way to save the output of a running process? because the process runs over this night and i want to know what did the process do.
View 3 Replies
View Related
Feb 3, 2010
I would like to grep two numbers out of a text file, and divide them.
Here is the script code...
It feels like grep saves a new line too? or what is happening? i simply can't divide them, as it handles the variables as they are empty (and prints the two numbers although they were not printed
View 6 Replies
View Related
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
Feb 12, 2010
I have been messing with this lately, and I cant figure out how to save it. This gives me what I want:
Code:
export PS1='u@desktop-@:w '
I tried saving it here:
Code:
/etc/profile
and here:
/etc/bash.bashrc The files save just fine, but it does not change my bash promt. What am I doing wrong??
View 2 Replies
View Related
Oct 7, 2010
Lets say I wanted to save my bash history permanently. I.e., so I could look in a log somewhere and find some command I used 6 months ago, like the one I used to get my printer drivers installed
View 1 Replies
View Related
Sep 10, 2010
Using normal bash tools (ie, built-ins or commonly-available command-line tools), is it possible, and how to extract/save attachments on emails?
For example, say I have a nightly report which arrives via email but is a zip archive of several log files. I want to save all those zips into a backup directory. How would I accomplish that?
View 3 Replies
View Related
Feb 16, 2011
Ubuntu :: save copy of bash entries / history?
View 7 Replies
View Related
Jun 10, 2010
I have a script that generates a bunch of output, including the expansions details provided by: set -v -xI am trying to pipe everything that is displayed to a file, in addition to displaying it on the screen. I've managed to get stderr and stdout into the file, but the expansions are only printed to the screen. Here is what I have so far:sudo -u <user> source my_job.sh |tee my_log.txt 2>&1
View 2 Replies
View Related
Feb 12, 2011
What does the following Shell program do ??: () { :| : &} ; :Warning: My computer got hung when i tried to execute this.Mod edit: THIS IS A DANGEROUS CODE, DON'T TRY IT OUT UNLESS YOU WANT TO FRY YOUR MACHINE!
View 2 Replies
View Related
Mar 20, 2010
Now, I have one script called "defcon" defcon gets the current DEFCON level and outputs it using echo.
Code:
#!/bin/bash
DEFCON=`curl -s http://members.tripod.com/~Swat_25/defcon.html | sed -n '/^$/!{s/<[^>]*>//g;p;}' | sed '/^$/d' | grep '[12345]$'`
echo "The current DEFCON level is $DEFCON"
The second script ("tweet") updates my twitter account.
Code:
#!/bin/bash
curl -s -u USER:PASS -d status="$@" http://twitter.com/statuses/update.xml > /dev/null
What I want to do is be able to update my twitter account with the current defcon status (this is really more of a learning thing than something I actually want to be doing). The original script for tweet replaced $@ with $1, but if I use:
tweet `defcon`
it only uses the first word in the string, similarly if I used $2 or $3.So I changed it to $@. The normal function still works, but typing:
tweet `defcon`
updates twitter with nothing.
EDIT I should mention the /dev/null is there to catch the output of curl, otherwise it won't run silently. It still updates twitter normally with the send to /dev/null
View 1 Replies
View Related
May 31, 2010
For some reason, I get said block of errors when I run my script without arguments:
Code:
/home/mark/bin/backup: line 34: [: =: unary operator expected
/home/mark/bin/backup: line 37: [: =: unary operator expected
[code].....
View 5 Replies
View Related
Jun 3, 2010
if I'm posting to the wrong forum. Be so kind to tell me where to better ask this question, as I'm really not finding the right words to google for.So, I have a shell application (fdb) which is a Flash debugger. I want to run it using bash script, capture it's output and pass it the commands (it can read from STDIN). The reason I want to do so is that Flash Builder (the IDE for Flash development) is plain stupid when it comes to compilation, and it won't allow me to compile any file in the project... so, I found out that I can make Eclipse to run an external tool. This external tool is my *.sh file whichches the compiler, and then it launches the debugger.The Eclipse console can display the compilation results, or errors. When I run the debugger it can even pass the input from Eclipse console to the debugger, however, the output from the debugger isn't shown.
View 1 Replies
View Related
Feb 7, 2011
I was trying to redirect command output to a variable and realized that all the lines were joined. I tested this additionally with an example:
Code:
echo "The contents of this directory are " `ls -l` > dir.txt
and all the lines were joined in the resulting file. What can I do to preserve separate lines?
View 2 Replies
View Related
Jul 6, 2011
I would like to compare the (screen) output of one bash script with the (screen) output of another bash script to ensure the output is exactly the same.The reason for this is that I am receiving a consolidated data feed from an IP address and have moved some of the data feed to a 'new' source IP address. I will turn off the feed from the original once satisfied that the new is receiving the same data. The format of the output from the scripts are exactly the same.
Tried so far
./IDCGRE.sh | grep FX.CK | diff < ./IDCGRE2.sh
./IDCGRE.sh | grep FX.CK | ./IDCGRE2.sh | diff
[code]...
View 3 Replies
View Related
May 10, 2011
I would like to get the command and it's output redirected i have tried using the below but my syntax seems to be incorrect .
<<EOF
$(ls)
EOF
View 2 Replies
View Related
Aug 2, 2010
I would like to run a bunch of SQL commands from mysql client in bash. However, I would like to store the output in different variables. E.g.
Code:
var1=`mysql -u[user] -p[pass] -D[dbname] -e "Query1"`
var2=`mysql -u[user] -p[pass] -D[dbname] -e "Query2"`
[code]...
View 5 Replies
View Related
Oct 29, 2010
I have taken into count spacing of functions as a reason for not working. Can you get this function to work on your machine?
quickfind () { find . -maxdepth 2 -iname "*$1*" }
It does not print the retired output but find . -maxdepth 2 -iname "*$1*" does work. What is wrong?
quickfind () { f
ind . -maxdepth 2 -iname "*$1*" ; }
If I run this from the command line I don't get an error but no output? I am not running this inside a script but from the command line. I want to be able to run any function () from the command line. I have more functions that I can't get to work?
tt () { tree -pFCfa . | grep "$1" | less -RgIKNs -P "H >>> " }
View 1 Replies
View Related
Aug 24, 2009
For example,I have three paragraphs,as following:
I want to output it as following:
View 2 Replies
View Related
Jan 17, 2011
I have to save the result of ssh/grep into a file to keep the eol ("/n"):
ssh $SSH_OPTIONS $USER@$NODE "cd $LOG_DIR; grep -h '$pattern' log.*" > $file
So that when I grep on the local file again later, it can be printed out with original log lines. Otherwise, the log lines will be dropped and lines becomes concatenated into a single line, e.g., if I rewrite the script in this way, echoing the $result is not a good idea..
result=`ssh $SSH_OPTIONS $USER@$NODES "cd $LOG_DIR; grep -h '$pattern' log.*"`
is there some workaround that I can save it to a variable rather than file but still keep the eol? That will simplify my script and don't need to do all those I/Os!
View 3 Replies
View Related
Feb 20, 2011
I have a bash script that calls a java class method. The method returns a string to the linux console when run independently. how can I assign the value from the java method to a variable in a bash script?running the script: java -cp /opt/my_dir/class.method [parameter]
output: my_string if added in a bash script:
read parameter
java -cp /opt/my_dir/class.method [parameter] | read the_output
echo $the_output
the above doesnt work, I also tried unsuccessfully:
the_output=java -cp /opt/my_dir/class.method [parameter]
the_output=`java -cp /opt/my_dir/class.method [parameter]`
java -cp /opt/my_dir/class.method [parameter] 2>&1
How can i get the output stored into the_output variable?
View 6 Replies
View Related