Sponsored Content
Top Forums Shell Programming and Scripting Script to change first line of files in directory Post 302653447 by Skrynesaver on Saturday 9th of June 2012 02:38:23 AM
Old 06-09-2012
Code:
for i in * ; do
  first=$(head -1 $i)
  head=$(echo $head | sed 's/ /_/')
  if [ "X$head" -eq "X" ] ; then
    head="blank"
  fi
  while [ -e $head ];do
    head="$head.1"
  done
  echo "mv $i $head" # if this looks good on the first pass, then uncomment the next line and try again
  #mv $i $head
done


Last edited by Skrynesaver; 06-11-2012 at 08:53 AM..
This User Gave Thanks to Skrynesaver For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How do I change ownership of a directory and all of it's files.

How do I change ownership of a directory and all of it's files without changing permissions? (1 Reply)
Discussion started by: mborin
1 Replies

2. Shell Programming and Scripting

Change Directory via a script?

I would like to have a script that would change my current working directory. However, any time I execute a 'cd' command in a script, it holds only for the life of that script -- the working directory on exit is the same as when the script was initiated. Is it possible to have the script return... (3 Replies)
Discussion started by: George Borrmann
3 Replies

3. Shell Programming and Scripting

Change of directory thru script

:confused: Hi All, This script is not working. I want to change the directory as per users selection in current shell. Looks like it is spawning sub-shell internally. I have used . changedir.sh source changedir.sh ./changedire.sh But did not work. Currently shell directory remain the... (4 Replies)
Discussion started by: shiningram
4 Replies

4. Shell Programming and Scripting

change directory using shell script

How do u change ur directory using a shell script?? (0 Replies)
Discussion started by: laxmi
0 Replies

5. Linux

Change directory in a shell script

How do u change ur directory using a shell script?? (12 Replies)
Discussion started by: laxmi
12 Replies

6. Shell Programming and Scripting

Script to change file contents line by line

Hi, I'm struggling to write a script to do the following, -will go through each line in the file -in a specific character positions, changes the value to a new value -These character positions are fixed througout the file ----------------------- e.g.: file1.sh will have the following 3... (4 Replies)
Discussion started by: vini99
4 Replies

7. Shell Programming and Scripting

directory change in shell script

Hi, I am trying to change the directory in my script, & want to check if the directory is present or not . Ex: cd /home/xyz/temp/logs if the logs directory is not present i want to show the error in script instead of shell script error. Can anybody please help me on the same Thx in... (2 Replies)
Discussion started by: vls1210
2 Replies

8. Shell Programming and Scripting

How to change a directory in shell script?

HI, I need to change the working directory by using the shell script /Export/home/user_name I have to go one step back like /Export/home Please help on this.:confused: (3 Replies)
Discussion started by: thelakbe
3 Replies

9. Shell Programming and Scripting

Apply 'awk' to all files in a directory or individual files from a command line

Hi All, I am using the awk command to replace ',' by '\t' (tabs) in a csv file. I would like to apply this to all .csv files in a directory and create .txt files with the tabs. How would I do this in a script? I have the following script called "csvtabs": awk 'BEGIN { FS... (4 Replies)
Discussion started by: ScKaSx
4 Replies

10. Shell Programming and Scripting

Change ? char from files and directory

Hello, I must change files and dirs name which contains che "?" char, I try this: rename 's/?/-/' *.* nothing, what's the problem? thanks (14 Replies)
Discussion started by: ionral
14 Replies
DOMDOCUMENT.SAVEHTMLFILE(3)						 1					       DOMDOCUMENT.SAVEHTMLFILE(3)

DOMDocument::saveHTMLFile - Dumps the internal document into a file using HTML formatting

SYNOPSIS
public int DOMDocument::saveHTMLFile (string $filename) DESCRIPTION
Creates an HTML document from the DOM representation. This function is usually called after building a new dom document from scratch as in the example below. PARAMETERS
o $filename - The path to the saved HTML document. RETURN VALUES
Returns the number of bytes written or FALSE if an error occurred. EXAMPLES
Example #1 Saving a HTML tree into a file <?php $doc = new DOMDocument('1.0'); // we want a nice output $doc->formatOutput = true; $root = $doc->createElement('html'); $root = $doc->appendChild($root); $head = $doc->createElement('head'); $head = $root->appendChild($head); $title = $doc->createElement('title'); $title = $head->appendChild($title); $text = $doc->createTextNode('This is the title'); $text = $title->appendChild($text); echo 'Wrote: ' . $doc->saveHTMLFile("/tmp/test.html") . ' bytes'; // Wrote: 129 bytes ?> SEE ALSO
DOMDocument::saveHTML, DOMDocument::loadHTML, DOMDocument::loadHTMLFile. PHP Documentation Group DOMDOCUMENT.SAVEHTMLFILE(3)
All times are GMT -4. The time now is 04:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy