09-09-2002
replacing contents of files from a bash script
I'm writing a shell script and I need to replace the contents of a configuration file based on what is passed to the script...can I replace expressions in a file from a bash shell script?
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi All,
I have a query on Perl. I have a text file which has 3 lines, i want to only replace the first line with my replaced text and keep the rest of the text. FOr eg
Before change -->
echo:a:pending
echo:b:pending
echo:c:pending
After change --->
echo:a:done
echo:b:pending... (1 Reply)
Discussion started by: tosatesh
1 Replies
2. Shell Programming and Scripting
I'm trying to change the ramfs size in kernel .config automatically.
I have a ramfs_size file generated with du -s
cat ramfs_size
64512
I want to replace the linux .config's ramdisk size with the above value
CONFIG_BLK_DEV_RAM_SIZE=73728
Right now I'm doing something dumb like: ... (3 Replies)
Discussion started by: amoeba
3 Replies
3. Shell Programming and Scripting
Ok,
I'm stuck here with a plan to get what I need done completed.
I want to use perl to produce a document. lets say the document will be a pdf document.
Now, is there a way for me to put a tiny little code in that pdf document that can make the pdf file null itself if run on a non-unix... (2 Replies)
Discussion started by: SkySmart
2 Replies
4. UNIX for Dummies Questions & Answers
I need to replace all filesnames in a folder as well as its content from AK6 to AK11. Eg Folder has files AK6-Create.xml, AK6-system.py etc.. the files names as well as contents should be changes to AK9-Create.xml, AK9-system.py etc
All files are xml and python scripts.
---------- Post... (0 Replies)
Discussion started by: Candid247
0 Replies
5. Shell Programming and Scripting
Hey guys,
need help with a script I'm trying to write.
Basically I need to compare the contents of a folder called "profiles"
with a list of files called "template".
when the file matches the contents of the folder it needs to set a variable called "checked" to "1"
Cookies to anyone... (4 Replies)
Discussion started by: Scriporium
4 Replies
6. Shell Programming and Scripting
Hi
i need Script to copy the contents of two files into one file
i have 2 fil X1.txt / X2.txt i need script to copy the contents of X1 and X2 In AllXfile
X1.txt
File X1
X2.txt
File X2
AllXfile.txt
File X1
File X2 (2 Replies)
Discussion started by: azzeddine2005
2 Replies
7. Shell Programming and Scripting
I have to hit a very large database to pull fields of information.
I have a script that runs multiple instance of the same query against the data base and writes contents to a file.
The script terminates before the file is completely written to confirmed by
ps -ef | grep <script name>... (3 Replies)
Discussion started by: popeye
3 Replies
8. Programming
I'm reading Operating Systems in Depth by Thomas W. Doeppner, and I have a question about execl. He says it's called after fork(), and that it replaces the text (code) of the current process and replaces it with the code of the new program. But that doesn't make sense to me.
Does that mean... (4 Replies)
Discussion started by: SirSalt
4 Replies
9. Shell Programming and Scripting
I need to cat two files with similar names. I am using the following script:
#!/bin/bash
if ]
then
file=$1
file2="${file%R1.fastq}R2.fastq"
echo fetching data from R2 file ...
sleep 3
cat $file $file2 > infile
else
echo "Input_file passed... (2 Replies)
Discussion started by: Xterra
2 Replies
10. UNIX for Beginners Questions & Answers
Hi
I want to replace time stamp in the following line
PROCNAME.Merge.exchMon.CODE.T_QSTART 08:45 read
assuming the new time stamp is 09:45 ; the line is getting replaced as below
:45 read
I'm trying to use the perl one liner in bash script
perl -pi... (4 Replies)
Discussion started by: charlie87
4 Replies
LEARN ABOUT NETBSD
script
SCRIPT(1) BSD General Commands Manual SCRIPT(1)
NAME
script -- make typescript of terminal session
SYNOPSIS
script [-adfpqr] [-c command] [file]
DESCRIPTION
script makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive
session as proof of an assignment, as the typescript file can be printed out later with lpr(1).
If the argument file is given, script saves all dialogue in file. If no file name is given, the typescript is saved in the file typescript.
Option:
-a Append the output to file or typescript, retaining the prior contents.
-c command
Run the named command instead of the shell. Useful for capturing the output of a program that behaves differently when associated
with a tty.
-d When playing back a session with the -p flag, don't sleep between records when playing back a timestamped session.
-f Flush output after each write. This is useful for watching the script output in real time.
-p Play back a session recorded with the -r flag in real time.
-q Be quiet, and don't output started and ended lines.
-r Record a session with input, output, and timestamping.
The script ends when the forked shell exits (a control-D to exit the Bourne shell (sh(1)), and exit, logout or control-d (if ignoreeof is not
set) for the C-shell, csh(1)).
Certain interactive commands, such as vi(1), create garbage in the typescript file. script works best with commands that do not manipulate
the screen, the results are meant to emulate a hardcopy terminal.
ENVIRONMENT
The following environment variable is used by script:
SHELL If the variable SHELL exists, the shell forked by script will be that shell. If SHELL is not set, the Bourne shell is assumed. (Most
shells set this variable automatically).
SEE ALSO
csh(1) (for the history mechanism).
HISTORY
The script command appeared in 3.0BSD.
BUGS
script places everything in the log file, including linefeeds and backspaces. This is not what the naive user expects.
BSD
October 17, 2009 BSD