General :: Adding # To First Line
Jun 23, 2011How Does sed or other command edit the 1st line in a file and comments it? Meaning add "#" to the first line in a file for example?
View 6 RepliesHow Does sed or other command edit the 1st line in a file and comments it? Meaning add "#" to the first line in a file for example?
View 6 RepliesI have a fairly long list of data that I am trying to put into a math program (maple) but before I can do that I need to edit the format of the data such that at the end of every 25th line I add a comma. I would prefer a solution that uses vi, but if that's impossible sed would be fine also (or awk).
View 6 Replies View RelatedI am looking at how to add particular text to a file in bash.Here is what I am trying to do:In the /etc/grub.conf file, I am trying to add "audit=1" (without the quotes) to the end of the kernel line...such as:kernel /vmlinuz-2.6.18-194.el5 ro root=LABEL=/1 rhgb quiet audit=1
As there are a few different lines in this file, I am only looking to add the "audit=1" to the above line via a bash script.
I wish to add information to one of my files based on matching IDs,
Here is an example
(the id is the 3 colunm)
(the ID is the 2 colunm)
And the output i wish to be
OUTPUT:
So as you can see the ones that do not match are still present, and the ones that do match just have the extra information from file2.txt added to them.
I thought about using join but that only seems to join the ones that match displays thoes only. i would like all the information in the output file.
I am trying to add a line of text to hgrc files for Mercurial Repo'sThe file is found normally in a hidden .hg directory under the repo.I need to add a "deny_read = username" to the end of each of these hgrc files. Suggestions either in shell script format, or a single line?
View 4 Replies View RelatedCouple of days I go I setup VLC using Kubuntu's graphic software manager, and installed the 3 plug-ins, one of which was related to pulse. After doing this sound stopped working in flash videos. I had read, not sure where, that Kubuntu didn't use pulse (which slipped my mind when setting up VLC).
So I make the mistake of removing everything which had pulse in it's name (again, via the graphic software manager). A message popped-up saying that some packages needed to be removed/edited (a LONG list, a big clue that I was doing something stupid I guess). I let it run it's course and after that it won't boot properly.
If I boot it normally it hangs at the Kubuntu screen with the five dots filling endlessly. If I press F1 it's stuck at "checking battery status."
Recovery mode boots, but the recovery option does nothing.
So I was wondering if I could boot into recovery mode and go into the terminal and add a live USB as a repository for apt, and try to salvage the install?
Or should I admit defeat and reinstall?
I was adding a line in terminal to try to get skype working and i added a line un-necessary and i need to edit the file. How do I either remove the file or edit it. It is a file in etc/yum.repos.d It says that it is read only, and i can't find how to change permissions.
View 2 Replies View Related- Off a vanilla F11 livecd install, I stuck a 3 at the end of my grub line to boot into runlevel 3. I have been doing this for as long as I can remember (since Fedora 3). However now it seems to break and gives me a GRUB error. I press e to edit, and delete the 3. BUt it still throws and error?!?!?!?! Has this facility (ie sticking a number at the end of the grub line) been changed and why is my grub line now broken even though I've gone back and deleted the 3?
- If I install Fedora 12 beta now, will yum take me all the way into production when it goes live (assuming no killer bugs encountered), I'm guessing thats a yes?
I've been compiling a lot of games recently and most of them requires me to add libX11 to the linker command line. I can't think of nothing but to take a look at the Makefile and add -lX11. It works, but now, I'm compiling from a git repo, and I know the change will removed once I update the my working copy.To make it short, is it possible to add libX11 permanently to the linker command line?
View 7 Replies View RelatedI'm trying to create a liveCD/USB for use of myself and my family. The idea is to set up the LiveCD to look like their used to seeing it. I know I can just copy the homedirectory but I wanted to do it via script so new user accounts could also have the common bells and whistles we use.So really I have two questions.1. Is it possible to add programs to the Gnome Tool Bar from command line? aka via a script2. Is it possible to modify the default panel template so new users get my changes?
View 1 Replies View RelatedI have a very large data file, with 3 numbers in each line, ex. 3 4 5 ; 6 7 8.I want to add two numbers (0 and 1) at the end of every line, and a string at the beginning of the line. Does anyone know a efficient way to do so?
View 7 Replies View RelatedI have added an application launcher to my desktop and it works fine. However, I want to be able to feed parameters to the launcher before I launch the application. So, for instance, if the command is normally "/usr/bin/foo something" I want to be able to add the "something" parameter dynamically after clicking the launcher but before the application launches. Is this possible in Fedora?
View 2 Replies View Relatedis it possible to do so? I mean, I want every user to be able to run '/bin/x' for example, as root without entering a password. I know the security risks, but I'm trying this in a risk-free environment which security does not matter very much.
View 2 Replies View RelatedHow to create cron tab when DSL line down set automatically restart the network service while DSL line up?
View 3 Replies View RelatedAfter running the following command, I get:
[root@yukiko /]# find / -iname .bashrc
/home/clamav/.bashrc
/home/vpopmail/.bashrc
/etc/skel/.bashrc
/root/.bashrc
But I would like to have a command that prints a specific line by supplying the command with the line number, for example:
[root@yukiko /]# find / -iname .bashrc | getline(2)
/home/vpopmail/.bashrc
Is there such a command on CentOS?
I have several files with many lines something like this:
I'm trying to write a script that will count the number of characters per line that doesn't contain a ">" symbol and give me an average of those values. I have most of the script together but I can't figure out how to connect some of the steps.
Code:
I am trying to write a script that takes an input file ($FileName) and an intermediate file ($FileName.info) and removes lines from $FileName if the value in $2 of $FileName.info is <75.
I can't figure out how to feed only one line of the .info file to the if statement at a time so that it will perceive it as an integer instead of a list.
The error I am getting now is ./script.sh: line 6: [: : integer expression expected
Sample input $FileName
Code:
Code:
Code:
Script so far:
Code:
I've written a script to parse a file and print each line that ends with matching pattern, if the next line is blank. The pattern lines are the result of md5sum $i|sed 's/path///g' so that only md5 and filename appear. Here's what I'm using.
Quote:
for fline in `sed -n '/.*.ext$/p' file1`
do
if [ "`sed -n -e '/'"$fline"'/ {n; p;}' file1`" == "" ]
then
echo ""$fline" has no info" >>file2
fi
done
[Code]....
I'd like show a certain line or lines of a file with context, kind of like a unified diff, on the command line in Linux:
$ (something) -l 154 stuff.py
150: def foo(bar):
151: """
[code]....
How can I print Linux command line history without including the line numbers? I want to send it all to a text file like this:history >> history.txt
View 1 Replies View RelatedI want to sort a number of lines based on their size:
data:
-------
12345678
87654321
1234
[code]....
Should output as:
-----------------
1
2
12
21
[code]....
But i'm gettings this with sort
----------------
1
12
123
1234
[code]....
Can we sort the above "data" text, based on "number of characters" instead of "character order"?
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
This solution works but is slow with large files. I am looking for a faster solution.
The 2 files contain filenames, one of them has associated data I want to append to the other file's matching filenames
file1:
file2:
I append file2 by matching the unique_filenames and appending them with the tag data and some formatting
appended file2:
Here is the SLOW code
while read inputline.
I need to grep for a particular string and if found need to display the line containing that string, the line above that and also the first line of that paragraph.
Can this be done via sed.
Eg, My Paragraphs
OA connectA
Enclosure:
Interconnect Module #6 Status:
Here, if I grep for Critical, it should display the following
Similarly if I grep for Degraded, it should display
I have to do several scripts and I have no idea of how to do this one: Make a script that read line by line the passwd file and prints in console.Hope you understand couse my english isso bad as you can see.Our teacher told us something like this:#!/bin/bashwhile read line doecho $lineadone < dispositiveexit
View 9 Replies View RelatedI have a dataset (see example below) that I would like to go through and copy all lines containing a certain string ("LGIG") plus the line immediately following that line to a new file. I have no problem grepping lines containing the string LGIG but I'm lost how to translate that to line number and shift up one line number for each instance of that string.
Example input file:
[code].....
I have the file abc.txt
cat abc.txt This is a test file Nothing is new in this world
I want to replace "This is a test file" to "Text is replaced"
Code:
FindString='This is a test file'
ReplaceString='Text is replaced'
Findarray=(`echo $FindString | tr ' ' ' '`)
[Code]....
But this is not effective. how to replace entire line either using sed or awk or any other utility.
I m writing a script to delete a line at particular location.
But i m unable to use variable for specifying line number.
For example.
Code:
works fine and deletes 7th line from my file
But
Code:
gives following error.
Code:
I am using xterm and sometimes when typing long commands into a small window, the command extends beyond the end of the line. On my old uni setup, when this happens, the cursor moves to the line below and you can see what text you have typed above however on my slack 13 setup, it overwrites the current line so you cannot see what you have typed! How can I set xterm to move onto the next line instead of overtyping?
View 14 Replies View RelatedI have two files (not sorted) and need to compare line by line (i.e. first line of file1 to be compared to all the lines of file2 and so as for the rest of file1). Output will be an array of length of file2. Any suggestion in BASH other than a grep inside two read line loops ( which is time consuming for files ~1000s of lines).
View 2 Replies View Related