Sponsored Content
Full Discussion: moving text within file
Top Forums Shell Programming and Scripting moving text within file Post 302343879 by summer_cherry on Friday 14th of August 2009 02:02:03 AM
Old 08-14-2009
line_move
Code:
if [ $# -ne 4];then
echo "Usage: line_move file_to_be_moved start_line_number end_line_number new_position"
fi
file=$1
start=$2
end=$3
position=$4
sed -n "${start},${end}p" ${file} > ${file}.tmp
sed -e "${start},${end}d" -e "${position}r ${file}.tmp" ${file}

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Moving part of Text in a file

Hi, I have this text in a file where I need to move part of the text.... <Relation1 OriginatingObjectID="Holding_1" RelatedObjectID="Party_1" id="Relation_1"> <OriginatingObjectType tc="4">Holding</OriginatingObjectType> <RelatedObjectType tc="6">Party</RelatedObjectType>... (4 Replies)
Discussion started by: mgirinath
4 Replies

2. Shell Programming and Scripting

sh: Inserting tabs and moving text to 1 line

I trying to extract certain text from a csv file and then placing it into another csv file, but having problems getting the data to placed in one line with tab separated fields. Basically would like to have text sent to interfaces.csv in one line seperated by tabs. As it currently places files... (6 Replies)
Discussion started by: 00000008
6 Replies

3. Shell Programming and Scripting

Finding & Moving Oldest File by Parsing/Sorting Date Info in File Names

I'm trying to write a script that will look in an /exports folder for the oldest export file and move it to a /staging folder. "Oldest" in this case is actually determined by date information embedded in the file names themselves. Also, the script should only move a file from /exports to... (6 Replies)
Discussion started by: nikosey
6 Replies

4. Shell Programming and Scripting

Moving a part of the text in a file

*************** #some other text ***************** *************** #some other text ***************** address1=1.1.1.1 address2=2.2.2.2 address3=3.3.3.3 I have a file where i need to push all the text starting from address1 till end of file to, below . Can anyone of you... (6 Replies)
Discussion started by: srikanthgoodboy
6 Replies

5. Shell Programming and Scripting

moving text with sed

Hi, I have a configuration file for solaris zones that I generate as part of another script but I need to move part of the text to the end of the file prior to execution and I'm having problems getting the syntax correct on the sed command. The file looks like this: create -b set... (7 Replies)
Discussion started by: wibbles
7 Replies

6. Shell Programming and Scripting

Need help in finding filesize , moving file , gzipping file

Hi , Please help with the following questions 1) how can i find size of a file ? i have written du -k $flname > s1 . Is this right ? Any other better suggeastions ? 2) how do I use mv command for moving the file ? I need the syntax with some examples 3) Command for printing the total... (1 Reply)
Discussion started by: Learning!
1 Replies

7. Shell Programming and Scripting

moving file

Hello ALL, i hope everyone is fine here. I have found some directories that have 777 permission with below command. find ./ -type d -perm 0777 e/uploads/ e/uploads/s1 j/uploads/ j/uploads/s1 I want that if there is any php|html|css file found in above directory so move those... (4 Replies)
Discussion started by: learnbash
4 Replies

8. UNIX for Advanced & Expert Users

Need help on moving .csv file from UNIX to windows file path

Need help on moving .csv file from unix to windows file path. (1 Reply)
Discussion started by: lakshmanraok117
1 Replies

9. UNIX for Dummies Questions & Answers

Help! With File Moving

Hello, This is my first post, so please forgive my obvious lack of UNIX knowledge. I am trying/needing to write a script that follows this functional flow: 1. Access a config file that contains format:<directory> <filetype> <daterange> <directory> <filetype> <daterange> <directory>... (2 Replies)
Discussion started by: WildBeard83
2 Replies

10. Shell Programming and Scripting

Match text to lines in a file, iterate backwards until text or text substring matches, print to file

hi all, trying this using shell/bash with sed/awk/grep I have two files, one containing one column, the other containing multiple columns (comma delimited). file1.txt abc12345 def12345 ghi54321 ... file2.txt abc1,text1,texta abc,text2,textb def123,text3,textc gh,text4,textd... (6 Replies)
Discussion started by: shogun1970
6 Replies
GREP(1) 						      General Commands Manual							   GREP(1)

NAME
grep - search a file for a pattern SYNOPSIS
grep [ option ... ] pattern [ file ... ] DESCRIPTION
Grep searches the input files (standard input default) for lines (with newlines excluded) that match the pattern, a regular expression as defined in regexp(6). Normally, each line matching the pattern is `selected', and each selected line is copied to the standard output. The options are -c Print only a count of matching lines. -h Do not print file name tags (headers) with output lines. -i Ignore alphabetic case distinctions. The implementation folds into lower case all letters in the pattern and input before interpre- tation. Matched lines are printed in their original form. -l (ell) Print the names of files with selected lines; don't print the lines. -L Print the names of files with no selected lines; the converse of -l. -n Mark each printed line with its line number counted in its file. -s Produce no output, but return status. -v Reverse: print lines that do not match the pattern. Output lines are tagged by file name when there is more than one input file. (To force this tagging, include /dev/null as a file name argument.) Care should be taken when using the shell metacharacters $*[^|()= and newline in pattern; it is safest to enclose the entire expression in single quotes '...'. SOURCE
/sys/src/cmd/grep.c SEE ALSO
ed(1), awk(1), sed(1), sam(1), regexp(6) DIAGNOSTICS
Exit status is null if any lines are selected, or non-null when no lines are selected or an error occurs. GREP(1)
All times are GMT -4. The time now is 04:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy