General :: Shell Script For Appending Data To A File?

Feb 8, 2011

this is how we append a file at command line its like

cat>>file.txt
adasds
^D

but how to write the code for appending a file in a shell script i tried but its not running

cho "the contents of the file before appending"
cat ab.txt
echo `cat >> ab.txt

[code]....

View 3 Replies


ADVERTISEMENT

Programming :: Shell Script - Appending File1 To End Of File2

Jun 21, 2010

I'm working on some code where I have two files. I know I can use cat file1 >> file2 to append file1 to the end of file2. What I was wondering is how I could append the first line of file 1 to the end of the first line of file2, then the second line, and so forth.

So if file1 was :
cat
dog
mouse

file2:
orange
red
blue

I want file2 to be:
orange cat
red dog
blue mouse

Also I need it to remove any duplicates from the same horizontal line.

View 5 Replies View Related

General :: Appending File Extensions To Filenames In Bash Scripts?

May 18, 2010

Suppose I have a variable called filename which contains the name of a file but the name does not contain an extension.

View 4 Replies View Related

General :: Command For Appending A Text At The Start Of Every Line And Save It Another File?

Mar 10, 2011

I wish to append a text at the start of every line and save it to another file without changing the original file.know the command

For example:
Orignal.txt
a.txt

[code]...

View 5 Replies View Related

General :: Appending To The Current Line In A File Instead Of Creating A New Line?

Apr 1, 2011

I am combining data from a couple different input files and creating an output file in a specific format. I notice that if I use the >> operator, information gets appended to a new line in my output file. This is useful, but if I'd like to append onto the CURRENT line, is there an easy way to do this? I've been googling around and see lots of complicated answers, nothing that suggests to me an easy way to do this. For example, if my output file looks like this:

b1a:] cat test
hello my name is
b1a:]

and I'd simply like to append "Bob", how can I do it? If I use

b1a:] echo Bob >> test
b1a:] cat test
b1a:] hello my name is
Bob
b1a:]

So what I would prefer is some command that would create the result:

hello my name is Bob

View 14 Replies View Related

General :: Compare Semicolon Separated Data In 2 Files Using Shell Script?

Nov 16, 2009

I have some data ( seperated by semicolon ) with close to 240 rows in a text file temp1. temp2.txt stores 204 rows of data ( seperated by semicolon ). I want to : Sort the data in both files by field1.i.e first data field in every row. compare the data in both files and print out the rows that are not equal in seperate files. I was trying to do this with excel using vlookup, without a great deal of success. hence, i'm exploring the shell script option.

Code:

temp1.txt
1000xyz400100xyzA00680xyz0;19722.83;19565.7;157.13;11;2.74;11.00
1000xyz400100xyzA00682xyz0;7210.68;4111.53;3099.15;216.95;1.21;216.94
1000xyz430200xyzA00651xyz0;146.70;0.00;0.00;0.00;0.00;0.00

[code]....

View 4 Replies View Related

General :: Appending To PROMPT_COMMAND In .bashrc

Sep 29, 2010

I have the following as my $PROMPT_COMMAND in .bashrc:

Code:
PROMPT_COMMAND='
if [ $TERM = "screen" ]; then
MYPWD="${PWD/#$HOME/~}"
[ ${#MYPWD} -gt 20 ] && MYPWD=..${MYPWD:${#MYPWD}-18}
echo -n -e "33k$MYPWD33\"
fi
'

I am trying to append items to my PROMPT_COMMAND in another script/on command line. If I do the following:

[Code]....

I get no error. I've echoed the value of $PROMPT_COMMAND in both cases and their output is exactly the same.

View 4 Replies View Related

General :: Appending Acpi=off To Grub Two

Mar 12, 2010

I have a Toshiba Satellite L505D-GS6000 it had windows7 on it when I bought it new. Needless to say windows just ran too slow. The only Ubuntu distro that would boot up was Karmic 9.10. I had to append the phrase acpi=off to get the live ISO to boot I had to type acpi=off after the word splash. I saw it would boot so I installed it as the only OS on this computer.

Now when I boot up I am hitting the power button once and the back on again to get to the grub. I hit the E key use my arrows down to the word splash type acpi=off. Then hit CTRL X to boot up. How do I put this permanently into Grub2.

View 10 Replies View Related

General :: Appending Text To Profile In Ubuntu?

Mar 21, 2011

I want to append following text to my profile file from script:

JAVA_HOME="/usr/lib/jvm/java-6-sun"
CATALINA_HOME="/usr/share/tomcat6"
CATALINA_BASE="/var/lib/tomcat6"
ANT_HOME="/usr/share/ant"
export JAVA_HOME CATALINA_HOME CATALINA_BASE ANT_HOME

Kindly let me know how can I accomplish this?

View 2 Replies View Related

General :: Read .gz File Direct On Shell/terminal Without Decompressing The File?

Dec 9, 2008

How can I read .gz file direct on shell/terminal without decompressing the file?
satimis

View 5 Replies View Related

General :: Shell Script That Adds Users Name To A File When The File Is Modified?

Mar 30, 2010

I need a shell script that will add the users name and date to a file when the user has modified the file, these files are within a group and only accessible to this group. But we need a way for people in the group to know who and when the file was last modified.

View 1 Replies View Related

General :: Convert Binary File In To Ascii File Using Shell Script?

May 23, 2011

i am trying to convert a binary file in to ASCII using shell script. this file contains multiple types of data like string, number, bcd, etc.

View 5 Replies View Related

General :: Printing From Bash Shell / Concatenate Files Into One File With File Names Included?

May 11, 2011

I am supposed to take some small files, and print them to a specific printer, such that the small files are concatenated into one file. The file name has to be included in the file that gets printed.

Should I be looking to concatenate the files into one file with the file names included, and then print them?

something like: -printfunction -printername < file*

View 7 Replies View Related

General :: Automatically Appending Date To Filenames Of Photos Imported Using Shotwell Or F-spot

Nov 26, 2010

Is there a way to automatically append date to the filenames of the photos imported using shotwell or f-spot?

View 9 Replies View Related

General :: Make Arithmetic Operation Of Data File With Script File?

Aug 31, 2010

I wonder how to arithmetic operation of our data file using any script program/command (like sed, cut,awk)for example my data.file is:

45 65 42
12 23 61
43 34 21

I want to multiply first column with 2 and add second column with 3 then it become

90 68 42
24 26 61
86 37 21

View 5 Replies View Related

General :: Data From Input File To Be Taken And Send To Output File?

Jul 24, 2010

I am new to shell scripting.What i am trying is to write a shell script which take the input file and output should like as mentioned below.Output file should have data till SOK (marked in red)from every second line and then the selected data(marked in green) from 4th line.So selected data from 2nd and 4th line in one line of O/P file and then similarly selected data from 6th and 8th line in second line of O/P file.Input File:

3c3
< c1111;11.11.11.11;pOK;SOK:abcde;Universe:aa
---

[code]...

View 14 Replies View Related

General :: Shell: Script On Each Line In A File

Jan 3, 2011

So if I have a file with a list of files:

file.txt
file1.a
file2.b
file3.c

and I wanted to perform a script using a loop or recursively on each of those files, is there any way that I could do this?

I saw that xargs might be able to help me.

Here is sorta what I want to do:

Code:
#!/bin/bash

cat file.txt | xargs?? # Some commands to turn each line into a variable

for var in ${@}; do # Some way to get each of the files

# script on each file

View 1 Replies View Related

General :: Quickest Way To Share File From Shell

Jul 30, 2010

I'm using Ubuntu minimal install (With no window manager). What is the quickest and easiest way to upload a file somewhere? Something like a script to pastebin would work.

View 2 Replies View Related

General :: (Shell Script) Choose Log File To Use

May 9, 2011

I have a small script that uses the find command to look for a log file named: backup_log.txt. And then uses the first value in the log file as a variable in the script later on. However, say there are two or more of these log files located in different directories, how would I let the user choose which log file will be the one to use, and then make that (fullpathtofile) the value of the variable that will be used.

View 5 Replies View Related

General :: Shell Scripting - For Each File In Directory

May 2, 2011

I am working on some homework, however i am not here to be spoon fed. I am trying to get the numerical modification date of each file in a folder. Ie lets say there is a file called bob and it was modified 2006-11-23. i want to get it into a variable as 20061123.

Now i currently have this code:

Code:

However for some reason my output is:

Quote:

See how the 2011 has been placed next to it? i ran it with -x and saw this:

Code:

However i do not know how to find a way around this?

View 11 Replies View Related

General :: Convert DOS Bat File To Shell Script?

Jun 21, 2010

I need to convert the following .bat file to a linux shell script.experienced and kind linux folks:

:: Import database schema
echo off
echo.

[code]....

View 2 Replies View Related

General :: Insert Texts In A File By Using Shell?

Jan 26, 2011

I'm using fedora 14...i would like to insert few texts to a file in shell prompt(may be useful in scripting for in the future)...for eg,

[root@ruby ~]# cat > hello
1
2
2

[code]....

so in the above file i need to add the line "new line added" near the number 4 in the above file ....how can be this done ...?

View 8 Replies View Related

General :: Ovewrite A File In Shell Script?

Dec 12, 2010

I want to overite a file using shell script.

i need to overite the file withe value of 2nd argument.

echo $2 > /home/dir/file.txt whether this will work? or what is the correct syntax?

View 2 Replies View Related

Ubuntu Servers :: Access The Data In .fbd Data File

Feb 19, 2011

We purchased a new database system at work last October, ditching the old system because of a lack of support from the vendor. This is a retail Point of Sale and Backoffice database system. I am not sure what system the new one runs on, but the system we replaced was a Firebird data base. The reason I am posting is because we are now in need of the information contained in the old database which was not completely imported into the new system.

Basically the problem is this: The database in on a Windows XP system and I found a copy of SQL Manager Lite 2008 on the system, which after quite a bit of studying, I figured out how to extract the database into a removable file. I have this file (178MB) on a USB stick in a file called Backoffice.fbd.

My studying suggests to me that I can get into this database with MySQL. I have never used this and have no clue how to do this. All I want to be able to do get into the database and create tab deliminated spreadsheet files for each of the database sections (Customers, Repairs, Sales History, stock files, etc.) Is it possible to do this with Ubuntu and MySQL and if so, can expert suggest one or two things to get me started. While a guided tutorial would be nice because I am not an expert, I am willing to learn on my own if someone could point me in the right direction.

View 3 Replies View Related

General :: How To Do Grap Data Between Two File

May 6, 2010

The first file is a "key" of second file. In the second file, the first word is the key of each line. Each key and sentence in second file ONLY have one line. The Second File have many lines with key, but not all the key is shown on file1, but file1's key MUST in the second file. How can I get the result like this: (Need to sort by the key from File1)

View 4 Replies View Related

General :: Using SED Or AWK To Cut Data From A File Between Certain Characters

Oct 23, 2010

I would like to create a .ksh script which cuts certain data from a document. I have tried to use SED and AWK and piping but its been some time since i have operated on Linux and my memory is patchy.

View 14 Replies View Related

General :: Shell Command To Display Contents Of A File?

Feb 23, 2010

shell command to display contents of a file? Like that of .txt or .html

View 9 Replies View Related

General :: Get The Shortest String In A Text File With Shell?

Apr 29, 2010

Assume I have a text file as belowabcdaaaaaaagfgkhahahahahahhahhgfThen gf would be returned

View 4 Replies View Related

General :: Find The Tag Value In Xml File Through Unix Shell Script?

Nov 3, 2010

the below tag is in the xml file. Now i want to find and extract the value of application name test1 and test2 one by one in the unix shell script. how to do this

<application name="test1">
</application>
<application name="test2">

[code]...

View 2 Replies View Related

General :: How To Look At History File In Unix Shell For User?

May 28, 2010

How to Look at history file in unix shell for a user, find 5 most often used commands.

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved