Sponsored Content
Top Forums UNIX for Dummies Questions & Answers [bash]Stripping lines from a list Post 302179970 by noratx on Saturday 29th of March 2008 08:10:52 AM
Old 03-29-2008
No offence taken. =)
I'm pretty much a newbie, so writing hideous scripts is what you do at the beginning (i think).

As you mentioned, i was only showing a part of the total script.
Here is the whole funcion in the script (the rest is working as it should).
Also, the script that i wrote here in the beginning, is a snippet from a testing script that i used. Before i make major changes in the original script (that worked before i started to change it from backing up my MySQL database to backing up my home directory), i make minor testing scripts just to see if the changes works as i want the to. Because of that, some names (like the list names) may not be the same.

Code:
list() {
list=/tmp/beacon.list
$ncftpls -u <user> -p <password> -x "-l1" <server> > $list
cat $list | nl
echo "Choose file: "
read file
list_to_var=`cat $list | nl | grep $file | sed -e "s/$file//g" -e "s/ //g" | column -t`
echo $list_to_var
break
$ncftpget -u <user> -p <password> <host> /tmp backup/homes/$list_to_var
echo "Dumpfile retreived."
echo "Do you want to restore it?  Y/N: "
read unpack_
case $unpack_ in
        [yY]*)
                echo "unpacking..."
                $bunzip2 $dump_path$list_to_var
                tarfile=tarfile.txt
                echo "$list_to_var" > $dump_path$tarfile
                tar_var="`awk '/tar/{gsub(/.bz2/, "")};{print}' $dump_path$tarfile`"
                echo $tar_var
                break
                $tar -tf $dump_path$tar_var > $dump_path$tar_list.txt
                tar_list=$dump_path$tar_list.txt
                cat $tar_list | awk -F/ '{print $1 "/" $2}' | nl
                echo "Choose which directory to extract by entering the correponding number or * for everything : "
                read tar_path
                echo "Enter the path where you want to unpack"
                echo "Eg. '/home', '/tmp/' or '.'"
                echo "Enter path :"
                read extract_path
                case $tar_path in
                        '')
                                $tar -xvf $dump_path$tar_var -C $extract_path;;
                        *)
                                extract=`cat $tar_list | awk -F/ '{print $1 "/" $2}' | nl | grep $tar_path| sed -e "s/$tar_path//g" -e "s/ //g" | column -t`
                                $tar -xvf $dump_path$tar_var $extract -C $extract_path;;
                esac
                echo "The directory/s $tar_list unpacked to $extract_path!"
                echo "Do you want to delete the file $tar_var? Y/N: "
                read delete_tar_var
                case $delete_tar_var in
                        [yY]*)
                                rm $dump_path$tar_var
                                echo "$tar_var deleted!";;
                        [nN]*)
                                echo "";;
                esac
                unpack;;
        [nN]*)
                echo "Ok, lets quit!" ;;
esac
rm $dump_path$list
rm $dump_pathtarfile.txt
rm $dump_pathtar_list.txt
}

The paths and programs are entered in the beginning of the total script (like ncftpls=/usr/local/bin/ncftpls), in case you would wonder why i use $ncftpls and such.
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

merging 2 lines with awk and stripping first two words

Hey all i am pretty new to awk... here my problem. My input is something like this: type: NSR client; name: pegasus; save set: /, /var, /part, /part/part2, /testpartition, /foo/bar,... (9 Replies)
Discussion started by: bazzed
9 Replies

2. Shell Programming and Scripting

stripping out non-numeric values in a list

hi all, i'm very new to scripting and have the folllowing issue. I have used a few commands to get a list of numbers, but I need to strip away the non-numeric ones, and then need a total of all values. any ideas? root@unixserver # cat myfile | awk '{print $8}'| sort -rn 1504 1344 896 704... (2 Replies)
Discussion started by: badoshi
2 Replies

3. Shell Programming and Scripting

Bash script - stripping away characters that can't be used in filenames

I want to create a temp file which is named based on a search string. The search string may contain spaces or characters that aren't supposed to be used in filenames so I want to strip those out. My thought was to use 'tr' with but the result is the opposite of what I want: $ echo "test... (5 Replies)
Discussion started by: mglenney
5 Replies

4. UNIX for Dummies Questions & Answers

Stripping down binaries

Hello, I am the CEO of Grand Tech Corporation. We are launching Linux NT and forgive me, but I do not know how to strip binaries down in Mandriva Linux. Can someone tell me a way to?:b: (2 Replies)
Discussion started by: Linux NT
2 Replies

5. Shell Programming and Scripting

Removing lines from one list from another list.

Hello, I was wondering if there was an easy way to take lines from a single-column list, and remove them from a second single-column list. For example, I want to remove the contents of list 1 from list 2. How would I do this? Contents of list 1: server1a server2b server3c server4a... (2 Replies)
Discussion started by: LinuxRacr
2 Replies

6. Shell Programming and Scripting

For x in a b c; { list; } (in lieu of do list; done) works (in bash) - why and how?

In this post I came across the cited construct. It works! while ... { list; } does not. man bash does not mention it (or, better, I didn't see it). Any reason for / behind this? Am I missing something? (5 Replies)
Discussion started by: RudiC
5 Replies

7. Shell Programming and Scripting

How to find the X highest values in a list depending on the values of another list with bash/awk?

Hi everyone, This is an exemple of inpout.txt file (a "," delimited text file which can be open as csv file): ID, Code, Value, Store SP|01, AABBCDE, 15, 3 SP|01, AABBCDE, 14, 2 SP|01, AABBCDF, 13, 2 SP|01, AABBCDE, 16, 3 SP|02, AABBCED, 15, 2 SP|01, AABBCDF, 12, 3 SP|01, AABBCDD,... (1 Reply)
Discussion started by: jeremy589
1 Replies

8. Shell Programming and Scripting

Stripping ret of the lines in a file (sed question)

Hi all, I didn't use SED for 20 years and was never an expert. So my current knowledge is about zero. Please be patient with me. I'm neither a native speaker. I have a huge dictionary file and want the rest of the lines stripped. Everything after (and including) the "/" should be stripped. I... (2 Replies)
Discussion started by: Hinnerk2005
2 Replies
gst-complete-0.8(1)						   User Commands					       gst-complete-0.8(1)

NAME
gst-complete-0.8, gst-complete - perform bash completion for gst-launch command lines SYNOPSIS
complete -Cgst-complete-0.8 gst-launch gst-complete [--gst-list-mm] [--gst-mm=string] [--print] DESCRIPTION
gst-complete-0.8 enables bash to provide context-sensitive tab completion for gst-launch command lines. See gst-launch(1) for the syntax of gst-launch command lines. You must have a version of bash that supports programmable completion. Such versions of bash provide the complete built-in command. gst-complete is a wrapper script that runs the latest installed version of gst-complete-X.X. For example, if both gst-complete-0.7 and gst- complete-0.8 are installed on your system, gst-complete runs gst-complete-0.8. OPTIONS
The following options are supported by gst-complete-0.8 and gst-complete: --help Display detailed usage message. You can also use -? to specify this option. The following options are supported by gst-complete only: --gst-list-mm List found major/minor versions. This option displays the versions that are available. --gst-mm=string Force major/minor version. This option enables you to specify a specific version to run, if you do not want to run the default version. --print Print wrapped command line. This option displays the command that will be run, and then runs the command. EXAMPLES
Example 1: Generating the Registry of Available Plugins by Running gst-compprep Run the following command in your .bash_profile or other appropriate place: example% complete -C gst-complete-0.8 gst-launch Example 2: Running the Wrapper Script and Displaying the Command Name example% gst-complete --print /usr/bin/gst-complete-0.8 FILES
The following files are used by this application: /usr/bin/gst-complete-0.Executable for bash completion for gst-launch /usr/bin/gst-complete Wrapper script that runs the latest installed version of gst-complete-X.X ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWgnome-media | +-----------------------------+-----------------------------+ |Interface stability |External | +-----------------------------+-----------------------------+ SEE ALSO
gst-compprep(1), gst-feedback(1), gst-inspect(1), gst-launch(1), gst-launch-ext(1), gst-md5sum(1), gst-register(1), gst-thumbnail(1), gst- typefind(1), gst-xmlinspect(1), gst-xmllaunch(1), gstreamer-properties(1), libgstreamer-0.8(3), libgstgetbits(3) NOTES
Original man page written by the GStreamer team at http://gstreamer.net/. Updated by Brian Cameron, Sun Microsystems Inc., 2004. SunOS 5.10 14 Oct 2004 gst-complete-0.8(1)
All times are GMT -4. The time now is 05:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy